i want to remove parts of a column in pandas for example.
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
i want that i looks like that
time parts
2020-03-08 1
2020-03-09 5
2020-03-10 9
2020-03-11 13
i tried plenty of commands but nothing works.
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
We usually do
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.