Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from datetime import datetime
  2.  
  3. def process_time(data, time_columns, format='%Y-%m-%d %H:%M:%S'):
  4.     # format for uber: '%m/%d/%y %H:%M'
  5.     # format for cabs: '%Y-%m-%d %H:%M:%S'
  6.     # IT PROCESSES IT IN PLACE!
  7.    
  8.     # if data_name is None ignore format
  9.     if data_name is None:
  10.         for time_col in time_columns:
  11.             data[time_col] = pd.to_datetime(data[time_col], format=format)
  12.             data[time_col] = data[time_col].apply(lambda x: datetime(month=x.month, year=x.year, day=1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement