Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x cumalative使用cumsum()在python ML中保存除日期列以外的所有其他列_Python 3.x_Pandas_Machine Learning_Tensorflow2.0 - Fatal编程技术网

Python 3.x cumalative使用cumsum()在python ML中保存除日期列以外的所有其他列

Python 3.x cumalative使用cumsum()在python ML中保存除日期列以外的所有其他列,python-3.x,pandas,machine-learning,tensorflow2.0,Python 3.x,Pandas,Machine Learning,Tensorflow2.0,我有这样的股票数据集 **Date Open High ... Close Adj Close Volume** 0 2014-09-17 465.864014 468.174011 ... 457.334015 457.334015 21056800 1 2014-09-18 456.859985 456.859985 ... 424.440002 424.440002 34483200 2 2014-09-

我有这样的股票数据集

     **Date        Open        High  ...       Close   Adj Close    Volume**
0 2014-09-17  465.864014  468.174011  ...  457.334015  457.334015  21056800
1 2014-09-18  456.859985  456.859985  ...  424.440002  424.440002  34483200
2 2014-09-19  424.102997  427.834991  ...  394.795990  394.795990  37919700
3 2014-09-20  394.673004  423.295990  ...  408.903992  408.903992  36863600
4 2014-09-21  408.084991  412.425995  ...  398.821014  398.821014  26580100
我需要对各列进行累计求和
Open、High、Close、Adj Close、Volume


我尝试了这个
df.cumsum()
,它显示了错误时间戳错误。

我认为处理交易数据最好创建
DatetimeIndex

#if necessary
#df['Date'] = pd.to_datetime(df['Date'])
df = df.set_index('Date')
然后,如有必要,对所有列进行累加:

df = df.cumsum()
如果只需要某些列的累积和:

cols = ['Open','High','Close','Adj Close','Volume']
df[cols] = df.cumsum()