Advertisement
furas

Python - pandas - datetime

Jun 29th, 2018
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. df = pd.DataFrame({
  4.     'time': ['00:00:01', '00:01:00', '01:00:00'],
  5.     'datetime': ['2018.06.29 00:00:01', '2018.06.29 00:01:00', '2018.06.29 01:00:00'],
  6. })
  7.  
  8. print('time:', df['time'].dtypes)
  9. print('datetime:', df['datetime'].dtypes)
  10.  
  11. df['time'] = pd.to_datetime(df['time'], format='%H:%M:%S')
  12. df['datetime'] = pd.to_datetime(df['datetime'], format='%Y.%m.%d %H:%M:%S')
  13.  
  14. print('time:', df['time'].dtypes)
  15. print('datetime:', df['datetime'].dtypes)
  16.  
  17. print(df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement