python在csv数据帧中的最高值



假设我从一个数据帧中获得一个列表,该列表为

list = [1, 3, 2, 6, 4, 2, 7, 4, 2, 6, 8]

我想要返回一个绘制最高识别值的数据帧。例如:

list2= [1, 3, 3, 6, 6, 6, 7, 7, 7, 7, 8]

如上面的示例所示,将生成一个新的列表。绘制找到的最高值。

我需要它在数据帧文件中作为自己的列返回。我的参考代码;

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
# read data frame
df = pd.read_csv('file.csv')
# numbers list: [1, 3, 2, 6, 4, 2, 7, 4, 2, 6, 8]
df['numbers']
# here will go the code you guys give me ###
df['highestnumbers'] = #####################

输出应该是一个列表

[1, 3, 3, 6, 6, 6, 7, 7, 7, 7, 8]

df['highestnumbers']=df['numbers'].expanding((.max((

最新更新