python - Parse multiple date column combinations with pandas read_csv -
I am importing a CSV file to a "Date" column on which and after many (~ 20) other columns That's the time of day. I have tried to use = parse_dates with read_cv but when I combine more than 1 pair of columns, I get one "ValueError: Date column arrival was already in dict" Arrival is the second column to read in parse_dates = dictionary. Here's what I'm doing (brief example):
DF = read_csv ('DH_timing_prep_stata_v4.csv' September = ',', index_col = 'pt_id', parse_dates = {'sch_appt_time_': ['Date', 'sch_appt_time'], 'arrival': ['date', 'arrival']})
If I change the name of column to parse properly:
'D_sch_appt_time _': ['date', 'sch_appt_time'], 'd_arrival' ['d_ar_image_', ' I just tried to rename the column after importing df.columns = [' Sch_appt_time_ ',' arrival ',' other ',' a Lam ... ']
The problem with this approach is that if I Dictionary reorder columns to any changes in parse_dates and hence the name change is no longer valid.
My goal is to end with the names of the same columns as in the CVS file, what is the best way to go about this?
Comments
Post a Comment