SHARE
TWEET

Untitled

a guest Jun 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. df=pd.read_csv('yourfile.csv')
  3.  
  4. df.columns=pd.to_timedelta(pd.Series(range(df.shape[1]))*7,'d')+pd.to_datetime('2019-04-19')
  5.      
  6. from datetime import datetime, timedelta
  7.  
  8. columns = ['New_%s' % str(i).zfill(2) for i in range(1,107)]
  9. fmt = '%B %d, %Y'
  10. start_date = 'April 19, 2019'
  11. current = datetime.strptime(start_date, fmt)
  12. date_columns = [datetime.strftime(current - timedelta(days = 7 * i), fmt) for i, _ in enumerate(columns)]
  13.      
  14. ['April 19, 2019',
  15.  'April 12, 2019',
  16.  'April 05, 2019',
  17.  'March 29, 2019',
  18.  'March 22, 2019',
  19.  'March 15, 2019',
  20.  'March 08, 2019',
  21.  'March 01, 2019',
  22.  'February 22, 2019',
  23.  'February 15, 2019',
  24.  'February 08, 2019',
  25.  ...
  26. ]
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