0

My DF looks like this:

enter image description here

I know how to split the column 'value' in two columns: gender_age and total:

es = pd.DataFrame([{'gender_age' : key, 'total' : value } for d in df_hist_data['value'].tolist() for key, value in d.items()])
 

which gives me this:

enter image description here

My problem is the column 'end_time'... If I try to simply concatenate both DFs:

rr = pd.concat([df_hist_data.drop('value', axis=1), es], axis=1)

gives me this - NaN instead of the dates:

enter image description here

Please, could you help me to expand also the values of the column end_time? Thanks

Hwebservices
  • 63
  • 3
  • 11
  • Take a close look at `df_hist_data` and `es` dataframe. The former has 84 rows, and the latter has 1259 rows. These two are not in the same shape of rows to be appended to each other. – TheFaultInOurStars Mar 31 '22 at 07:45
  • How do you see your end result in this case? – Vishal Kamlapure Mar 31 '22 at 07:47
  • Kiani I know that.. Thanks! What I need is that when the dataframe is expanded to 1259 rows, the values of the column 'end_time' need to 'repeat' accordingly and do not return NaN... I am struggling with that. – Hwebservices Mar 31 '22 at 07:48
  • Vishal Kamlapure the values of 'end_time' also expanded, repeating the values accordingly... – Hwebservices Mar 31 '22 at 07:50
  • I don't know why my question was marked as duplicated. My question has not been answered in the question they say it is duplicate... – Hwebservices Mar 31 '22 at 07:54

0 Answers0