在 Spyder 中,是否有某种方法可以像使用数组一样通过右键单击它来绘制数据框?
In Spyder, is there some way to plot a dataframe by right-clicking it like you can with arrays?
我最近发现您可以右键单击 Spyder 中的数组并快速绘制数据图。使用这样的示例数据:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Some numbers in a data frame
nsample = 440
x1 = np.linspace(0, 100, nsample)
y = np.sin(x1)
dates = pd.date_range(pd.datetime(2016, 1, 1).strftime('%Y-%m-%d'), periods=nsample).tolist()
df = pd.DataFrame({'dates':dates, 'x1':x1, 'y':y})
df = df.set_index(['dates'])
df.index = pd.to_datetime(df.index)
你可以进入Variable explorer,右击y,直接在console中得到如下内容:
这会给你这个:
相同的选项似乎不适用于 pandas 数据框:
当然,您可以轻松地选择 df.plot()
:
但我真的很喜欢右键单击选项来检查变量和数据框是否符合我在处理大量数据时所期望的方式。那么,有没有我必须导入的库?或者可能是设置中的某些内容?我还注意到控制台中发生的事情是这个小魔法:%varexp --plot y
,但似乎找不到数据帧的等效项。
感谢您的任何建议!
(这里是 Spyder 开发人员)这只是 Dataframes 缺少的一点功能,但它很容易实现。
请在我们的 issue tracker 中提出问题,这样我们就不会忘记在以后的版本中这样做。
我最近发现您可以右键单击 Spyder 中的数组并快速绘制数据图。使用这样的示例数据:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Some numbers in a data frame
nsample = 440
x1 = np.linspace(0, 100, nsample)
y = np.sin(x1)
dates = pd.date_range(pd.datetime(2016, 1, 1).strftime('%Y-%m-%d'), periods=nsample).tolist()
df = pd.DataFrame({'dates':dates, 'x1':x1, 'y':y})
df = df.set_index(['dates'])
df.index = pd.to_datetime(df.index)
你可以进入Variable explorer,右击y,直接在console中得到如下内容:
这会给你这个:
相同的选项似乎不适用于 pandas 数据框:
当然,您可以轻松地选择 df.plot()
:
但我真的很喜欢右键单击选项来检查变量和数据框是否符合我在处理大量数据时所期望的方式。那么,有没有我必须导入的库?或者可能是设置中的某些内容?我还注意到控制台中发生的事情是这个小魔法:%varexp --plot y
,但似乎找不到数据帧的等效项。
感谢您的任何建议!
(这里是 Spyder 开发人员)这只是 Dataframes 缺少的一点功能,但它很容易实现。
请在我们的 issue tracker 中提出问题,这样我们就不会忘记在以后的版本中这样做。