【发布时间】:2017-01-31 07:09:39
【问题描述】:
我有一列包含字符串作为日期时间,我正在尝试转换 迄今为止的专栏。即使 sn-p 没有抛出错误,它返回零(00:00:00),我请求您指导如何将 Week 列转换为 MM/dd/yyyy 日期格式。
import pandas as pd
import csv
from pandas import DataFrame
third = pd.read_csv('C:/Users/emailcombo.csv')
third = third.rename(columns={'Phone Number:': 'Phone Number:'})
fourth = pd.read_csv('C:/Users/The_Real_InfoCenter.csv')
fourth = fourth.rename(columns={'Phone Number: ': 'Phone Number:'})
merged = pd.concat([third, fourth], ignore_index = True)
df = DataFrame(merged)
df['Week:'] = pd.to_datetime(df['Week:'])
df.sort_values(['Week:'], ascending = [False])
df.to_csv('Z:/AWS/updatedinfocentertracker.csv', index=False)
print "Updating has been done"
【问题讨论】: