Home > Software engineering >  Replicate/duplicate first value (column A) over all columns in entire row
Replicate/duplicate first value (column A) over all columns in entire row

Time:10-27

Does anyone know, how to get from this:

A B C D E F G
Rate RS 1.0 1.0 1.0 1.0 1.0 1.0

to this:

A B C D E F G
Rate RS RS RS RS RS RS RS

CodePudding user response:

Try using slice assignment:

df[:] = df.iloc[0, 0]

Or if you want to specify the Rate index:

>>> df[:] = df.loc['Rate'].iloc[0]
>>> df
       A   B   C   D   E   F   G
Rate  RS  RS  RS  RS  RS  RS  RS
>>> 
  • Related