0

I would like to reduce multiple columns to one column in dataframe.

I created dataframe from CSV files. The dataframe looks like this:

name  price color madefrom madefrom material material material
Cloth 100   red   UK       NaN      NaN      Fabric   NaN
Glass 30    blue  NaN      USA      NaN      NaN      NaN
Mask  5     white UK       NaN      Fabric   Cloth    NaN
...

Now I want to get the first data that exists in the same column that has same name. Result that I expect will look like below

name  price color madefrom material
Cloth 100   red   UK       Fabric
Glass 30    blue  USA      NaN     # If value Does not exists, it remains NaN
Mask  5     white UK       Fabric  # Fabric Is First value for column name 'material'

Is there any proper way to do this?

0 Answers0