前提・実現したいこと
ある購買データを用いて
特定のターゲットに絞ったリストを
作成したいと考えています。
具体的にはある特定の値(アウトレット)を部分選択し、
他は削除したいと考えています。
色々試して質問がごちゃごちゃしてきたので、
最新の状態だけお見せします。
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-51-b2da77963fd8> in <module> ----> 1 del df[df['St_SalesChannel'] != 'アウトレット店'] ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in __delitem__(self, key) 3313 # there was no match, this call should raise the appropriate 3314 # exception: -> 3315 self._data.delete(key) 3316 3317 # delete from the caches ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\internals\managers.py in delete(self, item) 983 Delete selected item (items if non-unique) in-place. 984 """ --> 985 indexer = self.items.get_loc(item) 986 987 is_deleted = np.zeros(self.shape[0], dtype=np.bool_) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2655 'backfill or nearest lookups') 2656 try: -> 2657 return self._engine.get_loc(key) 2658 except KeyError: 2659 return self._engine.get_loc(self._maybe_cast_indexer(key)) pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() TypeError: '0 True Name: Channel, Length: 2474084, dtype: bool' is an invalid key
該当のソースコード
Python
1del group[group['Channel'] != 'アウトレット']
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。