Python 如何在pandas中将列设置为日期框中的索引

Python 如何在pandas中将列设置为日期框中的索引,python,pandas,Python,Pandas,我有这样一句话: dict = {'open': 245.04, 'high': 245.769, 'low': 244.7, 'close': 245.51, 'volume': 1489478, 'datetime': 1584451800000} 我想将其转换为日期框数据,并将datetime设置为索引 所以我试着: data=pd.DataFrame.from_dict(dict,orient='index') 然后我收到: 0 ope

我有这样一句话:

   dict = {'open': 245.04, 'high': 245.769, 'low': 244.7, 'close': 245.51, 'volume': 1489478, 'datetime': 1584451800000}
我想将其转换为日期框数据,并将datetime设置为索引

所以我试着:

data=pd.DataFrame.from_dict(dict,orient='index')
然后我收到:

                     0
open      2.450400e+02
high      2.457690e+02
low       2.447000e+02
close     2.455100e+02
volume    1.489478e+06
datetime  1.584452e+12

如何将datetime设置为索引?

IIUC注意不要将dict命名为dict,因为python有一个名为dict的变量


“你指的是索引,你能给我们看一下输出吗?谢谢你的回答,你能告诉我T是什么吗?”威廉姆费斯
df=pd.DataFrame.from_dict(d,orient='index').T.set_index('datetime')
                open     high    low   close     volume
datetime                                               
1.584452e+12  245.04  245.769  244.7  245.51  1489478.0