我有一个日期时间数据框,我想对其进行区分以找到最大的波动。 当我尝试df.diff时,我得到AttributeError:'numpy.ndarray'对象没有属性'diff' 有什么方法可以区分这个日期时间,还是只有删除日期并将其替换为整数后才能起作用?
注意:我不希望时间有所不同,只是希望输出随时间而有所不同。
fluc = PowerCurve()(df2010['FH'].iloc[0:743]/10)
fluc = fluc.diff(axis = 0, periods = 1)
ax.plot(df2010['Datetime'].iloc[0:743], fluc)
完整的文件如下:
df_data2010 = pd.read_csv("P11-B2010.csv", skiprows=[1], usecols=[2,3,5])
df2010 = pd.DataFrame(columns = ['Datetime', 'FH'])
df1 = pd.to_datetime(df_data2010['YMD'], format='%Y%m%d')
df2 = df_data2010[' HH'].astype('timedelta64[h]')
df2010['Datetime'] = df1 + df2
df2010['FH'] = pd.to_numeric(df_data2010[' FH'], errors ='coerce')
del df1
del df2
del df_data2010
df2010['FH'] = df2010['FH'].interpolate()
V_jan2010 = df2010['FH'].iloc[0:743] / 10
fig, (ax) = plt.subplots()
ax.plot(df2010['Datetime'].iloc[0:743], V_jan2010, label='jan 2010')
fig, (ax1) = plt.subplots()
from Pcurve2 import PowerCurve
f = PowerCurve()
fluc = PowerCurve()(df2010['FH'].iloc[0:743]/10)
fluc = fluc.diff(axis = 0, periods = 1)
ax1.plot(df2010['Datetime'].iloc[0:743], fluc)