SHARE
TWEET

Python - pandas - datetime

furas Jun 29th, 2018 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top