Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.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 将索引转换为列数据帧_Python_Pandas_Dataframe - Fatal编程技术网

Python 将索引转换为列数据帧

Python 将索引转换为列数据帧,python,pandas,dataframe,Python,Pandas,Dataframe,我有以下数据帧: | id | LocTime |ZPos | XPos datetime | 2017-01-02 00:14:39 |20421902611| 12531245409231| 0 | -6 2017-01-02 00:14:40 |30453291020| 28332479673070| 0 | -2

我有以下数据帧:

                    |     id    |  LocTime        |ZPos   | XPos
datetime            |               
2017-01-02 00:14:39 |20421902611|   12531245409231| 0     | -6              
2017-01-02 00:14:40 |30453291020|   28332479673070| 0     | -2  
我想将日期时间索引转换为数据帧的列。 我尝试了
df.reset_index(level=['datetime'])
,但结果没有改变。
有什么想法吗

需要将输出分配回原位或
inplace=True
参数:

df = df.reset_index()


df.reset_index(inplace=True)
print (df)
              datetime           id         LocalTime  ZPosition  XPosition
0  2017-01-02 00:14:39  10453190861  1483312478909238          0         -9
1  2017-01-02 00:14:40  10453191020  1483312479673076          0         -8