gpt4 book ai didi

python - Pandas 数据帧类型错误 : quantile() missing 1 required positional argument: 'quantile' ?

转载 作者:行者123 更新时间:2023-12-04 10:28:14 25 4
gpt4 key购买 nike

数据

data = [
{"content": "1", "title": "app sotre", "info": "", "time": 1578877014},
{"content": "2", "title": "app", "info": "", "time": 1579877014},
{"content": "3", "title": "pandas", "info": "", "time": 1582877014},
{"content": "12", "title": "a", "info": "", "time": 1582876014},
{"content": "33", "title": "apple", "info": "", "time": 1581877014},
{"content": "16", "title": "banana", "info": "", "time": 1561877014},
{"content": "aa", "title": "banana", "info": "", "time": 1582876014},
]

我的代码
df = pd.DataFrame(data)
df['content'] = pd.to_numeric(df['content'], errors='coerce')
print('-----')
print(df['content'].rolling(2).quantile())

引发错误:类型错误:分位数()缺少 1 个必需的位置参数:“分位数”

最佳答案

我认为问题是没有默认 quantile Rolling.quantile :

print(df['content'].rolling(2).quantile(0.5))

但是如果检查所有其他方法,总会有默认的分位数:

Series.quantile , DataFrame.quantile , DataFrameGroupBy.quantile , Resampler.quantile .

关于python - Pandas 数据帧类型错误 : quantile() missing 1 required positional argument: 'quantile' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60540241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com