Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.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 o_datetime创建新列而不是更改现有列_Python_Pandas_Dataframe - Fatal编程技术网

Python o_datetime创建新列而不是更改现有列

Python o_datetime创建新列而不是更改现有列,python,pandas,dataframe,Python,Pandas,Dataframe,现在要和这个摔跤7个小时了。我需要一些帮助 问题:使用Pandas的to_datetime函数,正在创建新列,而不是转换现有列 在我的代码下面,它将在脚本文件的相同位置获取csv文件 import os import numpy import pandas as pd from os import path import datetime script_path = os.path.dirname(os.path.realpath(__file__)) table_fqfn = script_p

现在要和这个摔跤7个小时了。我需要一些帮助

问题:使用Pandas的
to_datetime
函数,正在创建新列,而不是转换现有列

在我的代码下面,它将在脚本文件的相同位置获取csv文件

import os
import numpy
import pandas as pd
from os import path
import datetime
script_path = os.path.dirname(os.path.realpath(__file__))
table_fqfn = script_path + "\\date_chairperson.csv"
df = pd.read_csv(table_fqfn)
#CONVERT DATA TYPES
print (type(df['meeting_date']))
print (df.dtypes)
print (df)
df['new_meeeting_date'] = pd.to_datetime(df['meeting_date'])
print (type(df['meeting_date']))
print (df.dtypes)
print (df)
print (df['new_meeting_date'])
看起来像这样

如果我故意让Python创建一个包含转换日期的新列

df['new_meeeting_date'] = pd.to_datetime(df['meeting_date'])
这是理所当然的

但是,尝试访问它时:

打印(df[“新会议日期])


存在打字错误
eee
-
df['new\u meeting\u date']=pd.to\u datetime(df['meeting\u date'])
如果需要更改现有的,为什么不重新分配<代码>df['meeting_date']=pd.to_datetime(df['meeting_date'])?啊!就在那里!7小时!非常感谢你!!!