Skip to content Skip to sidebar Skip to footer

Preventing Timestamp Creation In To_datetime() Formatting In Order To Group By Periods

My pandas df3 is very large and roughly looks like this: df3 = pd.DataFrame([['23.02.2012', '23.02.2012', 'aaa'], ['27.02.2014', '27.02.2014', 'bbb'], ['17.08.2018', '17.08.2018',

Solution 1:

How about splitting by \n and using the first element ? This will "clean" the data.

Something like the below:

val1 = '27.02.2014\nwer'
val2 = '27.02.2014'

date1 = val1.split('\n')[0]
date2 = val2.split('\n')[0]
print(date1)
print(date2)

output

27.02.2014
27.02.2014

Post a Comment for "Preventing Timestamp Creation In To_datetime() Formatting In Order To Group By Periods"