I have the following dataframe
NDQ CFRI NFFV [more columns....]
2002-01-24 92.11310000 57.78140000 90.95720000
2002-01-25 57.97080000 91.05430000 58.19820000
I want to set all values in a column equal to the maximum value of the respective column.
Desired output:
NDQ CFRI NFFV [more columns....]
2002-01-24 92.11310000 91.05430000 90.95720000
2002-01-25 92.11310000 91.05430000 90.95720000
I have attempted to map it out to the result of df.max()
, but struggled with the implementation and also feel like there would be an easier solution available.
Any help would be greatly appreciated.
To set all values in a column equal to the maximum value of the respective column I would suggest to follow below code.
df['NDQ']=df.NDQ.max()
or
df['NDQ_Max']=df.NDQ.max()
df.clip
is used to Assigns values outside boundary to boundary values. But as you want to set all the values in a particular values you may not need to use that. Please see the link
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.clip.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.