Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas, numpy, StringIO
- txt = '''ID,RUN_START_DATE,PUSHUP_START_DATE,SITUP_START_DATE,PULLUP_START_DATE
- 1,2013-01-24,2013-01-02,,2013-02-03
- 2,2013-01-30,2013-01-21,2013-01-13,2013-01-06
- 3,2013-01-29,2013-01-28,2013-01-01,2013-01-29
- 4,2013-02-16,2013-02-12,2013-01-04,2013-02-11
- 5,2013-01-06,2013-02-07,2013-02-25,2013-02-12
- 6,2013-01-26,2013-01-28,2013-02-12,2013-01-10
- 7,2013-01-26,,2013-01-12,2013-01-30
- 8,2013-01-03,2013-01-24,2013-01-19,2013-01-02
- 9,2013-01-22,2013-01-13,2013-02-03,
- 10,2013-02-06,2013-01-16,2013-02-07,2013-01-11'''
- df = pandas.read_csv(StringIO.StringIO(txt))
- Bigdata_date_tofix = [c for c in df.columns if 'DATE' in c]
- df[Bigdata_date_tofix] = df[Bigdata_date_tofix].apply(pandas.to_datetime)
- as_indx = df[['RUN_START_DATE', 'PUSHUP_START_DATE', 'SITUP_START_DATE', 'PULLUP_START_DATE']].apply(numpy.argsort, axis=1)
- ############# RESULT #####################
- '''
- RUN_START_DATE PUSHUP_START_DATE SITUP_START_DATE \
- 0 1970-01-01 00:00:00 1970-01-01 00:00:00 2262-04-10 00:12:43.145224
- 1 3 2 1
- 2 2 1 0
- 3 2 3 1
- 4 0 1 3
- 5 3 0 1
- 6 1970-01-01 00:00:00 2262-04-10 00:12:43.145224 1970-01-01 00:00:00
- 7 3 0 2
- 8 1970-01-01 00:00:00 1970-01-01 00:00:00 1970-01-01 00:00:00
- 9 3 1 0
- PULLUP_START_DATE
- 0 1970-01-01 00:00:00
- 1 0
- 2 3
- 3 0
- 4 2
- 5 2
- 6 1970-01-01 00:00:00
- 7 1
- 8 2262-04-10 00:12:43.145224
- 9 2
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement