gpt4 book ai didi

python - Pandas 图(种类 ='line' )创建散点图

转载 作者:行者123 更新时间:2023-12-05 00:44:45 27 4
gpt4 key购买 nike

我正在尝试绘制 pandas Series用一条线。
这些线产生显示的输出和散点图。

import pandas as pd
print(pd.__version__)
...
print(type(sam))
print(sam)
sam.plot(kind='line');

0.25.3
<class 'pandas.core.series.Series'>
3300 0.87
3301 0.87
3302 0.87
3303 0.87
3304 0.87
Name: A, dtype: float64

<<SCATTER PLOT>>

我无法通过 Series.plot 以任何方式创建线图.

正确的做法是什么?

PS:我可以想出解决方法,比如创建新的 np数组、列表等
但我想这应该立即起作用。

PS2:我在 PortableApps 的 Chrome 下使用 Jupyter Lab。
奇怪的是,在实验室的一个选项卡中(很少有东西),上面的线生成了一个线图,在另一个选项卡中(加载了 sklearn),它生成了一个散点图。
我将进一步试验。

最佳答案

你可以试试:

sam = pd.Series([.87,.87,.87,.87,.87], index=range(3300, 3305))

系列:
3300    0.87
3301 0.87
3302 0.87
3303 0.87
3304 0.87
dtype: float64

线图:
sam.plot()

enter image description here
sam.plot(kind='line')呈现相同的输出。

关于python - Pandas 图(种类 ='line' )创建散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59337416/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com