如果我有一些虛構(gòu)的數(shù)據(jù)...如何只打印在名為 的列中找到的最大值的索引(日期和時(shí)間戳)Temperature?import numpy as npimport pandas as pdnp.random.seed(11)rows,cols = 50000,2data = np.random.rand(rows,cols) tidx = pd.date_range('2019-01-01', periods=rows, freq='H') df = pd.DataFrame(data, columns=['Temperature','Value'], index=tidx)maxy = df.Temperature.max()maxDate = df.loc[df['Temperature'].idxmax()]如果我打印maxDate有很多不需要的信息..print(maxy)print(maxDate)這輸出:0.9999949674183947Temperature 0.999995Value 0.518413Name: 2023-01-06 02:00:00, dtype: float64最終我希望創(chuàng)建一個(gè)f只打印的字符串maximum temperature recorded in the dataset is 0.999995 found on 2023-01-06 02:00:00,沒有額外的信息,例如Name:和, dtype: float64和Value 0.518413列......感謝任何提示和技巧
熊貓打印在帶有 f 字符串的列中找到的最大值
繁華開滿天機(jī)
2022-12-20 16:20:11