python typeerror对象不支持_python - TypeError:'type'对象不支持循环熊猫的项目分配 - SO中文参考 - www.soinside.com...

博客围绕Python中提取数据框特定月份数据展开。给出了提取所有年份中月份名称为Jan、Feb等数据的代码示例,在使用循环存储各月份数据时出现TypeError: 'type' object does not support item assignment错误,打印数据帧则正常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

dfmonth year Jelly Candy Ice_cream.....and so on

JAN 2010 12 11 10

FEB 2010 13 1 2

MAR 2010 12 2 1

....

DEC 2019 2 3 4

用于提取所有年份的月份名称均为Jan,Feb等的数据框的代码。例如。[IN]filterJan=df[df['month']=='JAN']

filterJan

[OUT]

month year Jelly Candy Ice_cream.....and so on

JAN 2010 12 11 10

JAN 2011 13 1 2

....

JAN 2019 2 3 4

我正在为此过程做一个循环。[IN]for month in ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']:

filter[month]=df[df['month']==month]

[OUT]

----> 3 filter[month]=batch1_clean_Sales_database[batch1_clean_Sales_database['month']==month]

TypeError: 'type' object does not support item assignment

如果我打印数据帧,它正在工作,但是我想存储它们并以后再使用它们[IN]for month in ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']:

print(df[df['month']==month])

df月年果冻糖果冰淇淋.....等等,2010年1月12 11 10月2日13 1 2 MAR 2010 12 2 1 .... DEC 2019 2 3 4提取数据帧的代码...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值