我想删除熊猫中一列的一部分 例如。
time parts
2020-03-08T17:00:00+0000 1
2020-03-09T17:00:00+0000 5
2020-03-10T17:00:00+0000 9
2020-03-11T17:00:00+0000 13
我希望我看起来像这样
time parts
2020-03-08 1
2020-03-09 5
2020-03-10 9
2020-03-11 13
我尝试了很多命令,但是没有用。
Index(['Unnamed: 0', 'time_iso8601', 'DE-SH', 'DE-HH', 'DE-NI', 'DE-HB',
'DE-NW', 'DE-HE', 'DE-RP', 'DE-BW', 'DE-BY', 'DE-SL', 'DE-BB', 'DE-MV',
'DE-SN', 'DE-ST', 'DE-TH', 'DE-BE', 'sum_cases'],
dtype='object')
Unnamed: 0 time_iso8601 DE-SH
0 0 2020-03-02T17:00:00+0000 4
1 1 2020-03-03T17:00:00+0000 5
2 2 2020-03-04T17:00:00+0000 5
3 3 2020-03-05T17:00:00+0000 6
答案 0 :(得分:1)
我们通常这样做
df.time_iso860=pd.to_datetime(df.time_iso860).dt.date
df
Out[27]:
time_iso860 parts
0 2020-03-08 1
1 2020-03-09 5