[英]get Max value for panda series
我有这个数据
[list([29]) nan list([40])]
类型是熊猫系列
print(type([list([29]) nan list([40])]))
//type <class 'pandas.core.series.Series'>)
现在我需要得到最大值,显然是 40,所以我尝试了
hi = [list([29]) nan list([40])]
hi = hi.nlargest(1)
print(hi)
// should be
40
但返回错误
raise TypeError(f"Cannot use method '{method}' with dtype {dtype}")
TypeError: Cannot use method 'nlargest' with dtype object
有任何想法吗?
问候,
尝试
# flatten the series with explode and find max
pd.Series([list([29]), np.nan, list([40])]).explode().max()
# 40
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.