Python o_datetime创建新列而不是更改现有列
现在要和这个摔跤7个小时了。我需要一些帮助 问题:使用Pandas的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
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小时!非常感谢你!!!