切片数据帧时的KeyError

时间:2018-05-08 18:21:33

标签: python pandas dataframe indexing slice

我的代码如下:

    for sel in name:
        self.counter += 1
        sel = "https://www.amazon.co.uk"+sel
        request = scrapy.Request(sel, callback=self.seller_information , meta={'item': item} , dont_filter=True)
        yield request

# Need to check for some empty values : almost done
def seller_information(self,  response):
    item = response.request.meta['item']
    item['seller_name'] = response.xpath('//h1[contains(@id , "sellerName")]/text()').extract()
    yield item

当我运行它时,我得到一个KeyError,它读取['DRY DENSITY''R.C。']而不是索引。我修改了.csv中列的名称是正确的。为什么这两个列会出现问题?

1 个答案:

答案 0 :(得分:2)

我认为需要加倍RewriteEngine On RewriteRule /^(\w{2})\-(\w{2})/(.+)$ /content/company/$1/$2/$3 [L]

[[]]

如果某些列正在添加intersection

cols = ['TEST #', 'DATE', 'TESTED BY', 'NORTH', 'EAST', 'TEST ELEVATION', 'CURVE #', 'OPT. M.C.', 'FIELD M.C.', 'DRY DENSITY', 'R.C.', 'RETEST #', 'NOTES']
dfb = dfa[cols]