1

I'm processing my data from MIMIC dataset. Some of my data are like that: (the data type is pandas.dataframe)

time  A  B  C D
01:00 2 NaN 3 4
02:00 2 NaN 3 4
03:00 2 NaN 3 4
01:00 NaN 4 3 4

NaN means missing data.

Obviously line 1 and line 4(they are token in same time) should be combined. But how can I do that?

The output I need is like:

time  A  B  C D
01:00 2  4  3 4
02:00 2 NaN 3 4
03:00 2 NaN 3 4
潘嶓 Bo Pan
  • 383
  • 1
  • 4
  • 7

1 Answers1

0

If you want to sum the other rows , here is the code :

df.groupby(['time']).sum() 

or

df.groupby(['time']).max() 

for more : https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html

r.burak
  • 514
  • 5
  • 10