python中列_Python中的列选择

---------------------------------------------------------------------------ValueErrorTraceback(most recent call last)C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\common.pyin_asarray_tuplesafe(values,dtype)376result=np.empty(len(values),dtype=object)-->377result[:]=values378exceptValueError:ValueError:couldnotbroadcast input arrayfromshape(31807,0)into shape(31807)Duringhandling of the above exception,another exception occurred:ValueErrorTraceback(most recent call last)C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\frame.pyin_ensure_valid_index(self,value)2375try:->2376value=Series(value)2377except:C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\series.pyin__init__(self,data,index,dtype,name,copy,fastpath)247data=_sanitize_array(data,index,dtype,copy,-->248raise_cast_failure=True)249C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\series.pyin_sanitize_array(data,index,dtype,copy,raise_cast_failure)3028else:->3029subarr=_asarray_tuplesafe(data,dtype=dtype)3030C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\common.pyin_asarray_tuplesafe(values,dtype)379# we have a list-of-list-->380result[:]=[tuple(x)forxinvalues]381ValueError:cannot copy sequencewithsize0to array axiswithdimension31807Duringhandling of the above exception,another exception occurred:ValueErrorTraceback(most recent call last)in()11df.columns=df.columns.str.upper()12#print(list(df.columns))--->13df1['Isbn']=df[df.columns[df.columns.str.contains('|'.join(searchfor))]]14df1['Title']=df[df.columns[df.columns.to_series().str.contains('|'.join(searchfor1))]]15df1['Curr']=df[df.columns[df.columns.to_series().str.contains('|'.join(searchfor2))]]C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\frame.pyin__setitem__(self,key,value)2329else:2330# set column->2331self._set_item(key,value)23322333def_setitem_slice(self,key,value):C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\frame.pyin_set_item(self,key,value)2394""" 2395

-> 2396 self._ensure_valid_index(value) 2397 value = self._sanitize_column(key, value) 2398 NDFrame._set_item(self, key, value)

C:\Users\Ruchir_Kumar_Jha\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\core\frame.py in _ensure_valid_index(self, value) 2376 value = Series(value) 2377 except:

-> 2378 raise ValueError('Cannot set a frame with no defined index ' 2379 'and a value that cannot be converted to a ' 2380 'Series')

ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值