前提・実現したいこと
pnadasを用いて、placeVistで始まる行を抽出したいのですが、
str.containsを用いてもすべての行がNANになってしまい抽出できません。
なぜでしょうか。
発生している問題・エラーメッセージ
KeyError Traceback (most recent call last) <ipython-input-17-5a88b0472f7f> in <module> ----> 1 placeVisit = timelineObjects[timelineObjects['timelineObjects'].str.contains('placeVisit')] 2 placeVisit ~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 2906 if is_iterator(key): 2907 key = list(key) -> 2908 indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1] 2909 2910 # take() does not accept boolean indexers ~\anaconda3\lib\site-packages\pandas\core\indexing.py in _get_listlike_indexer(self, key, axis, raise_missing) 1252 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr) 1253 -> 1254 self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing) 1255 return keyarr, indexer 1256 ~\anaconda3\lib\site-packages\pandas\core\indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing) 1296 if missing == len(indexer): 1297 axis_name = self.obj._get_axis_name(axis) -> 1298 raise KeyError(f"None of [{key}] are in the [{axis_name}]") 1299 1300 # We (temporarily) allow for some missing keys with .loc, except in KeyError: "None of [Float64Index([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,\n nan, nan, nan, nan, nan, nan, nan, nan, nan],\n dtype='float64')] are in the [columns]"
該当のソースコード
python3
1placeVisit = timelineObjects[timelineObjects['timelineObjects'].str.contains('placeVisit')] 2placeVisit
元データ
timelineObjects
0 {'placeVisit': {'location': {'latitudeE7': 353...
1 {'activitySegment': {'startLocation': {'latitu...
2 {'placeVisit': {'location': {'latitudeE7': 353...
3 {'activitySegment': {'startLocation': {'latitu...
4 {'placeVisit': {'location': {'latitudeE7': 353...
5 {'placeVisit': {'location': {'latitudeE7': 353...
6 {'activitySegment': {'startLocation': {'latitu...
7 {'placeVisit': {'location': {'latitudeE7': 353...
8 {'activitySegment': {'startLocation': {'latitu...
9 {'placeVisit': {'location': {'latitudeE7': 353...
10 {'activitySegment': {'startLocation': {'latitu...
11 {'placeVisit': {'location': {'latitudeE7': 353...
12 {'activitySegment': {'startLocation': {'latitu...
13 {'placeVisit': {'location': {'latitudeE7': 353...
14 {'activitySegment': {'startLocation': {'latitu...
15 {'placeVisit': {'location': {'latitudeE7': 353...
16 {'activitySegment': {'startLocation': {'latitu...
17 {'placeVisit': {'location': {'latitudeE7': 353...
18 {'activitySegment': {'startLocation': {'latitu...
19 {'placeVisit': {'location': {'latitudeE7': 353...
20 {'placeVisit': {'location': {'latitudeE7': 353...
21 {'activitySegment': {'startLocation': {'latitu...
22 {'placeVisit': {'location': {'latitudeE7': 353...
23 {'activitySegment': {'startLocation': {'latitu...
24 {'placeVisit': {'location': {'latitudeE7': 353...
25 {'activitySegment': {'startLocation': {'latitu...
26 {'placeVisit': {'location': {'latitudeE7': 353...
27 {'activitySegment': {'startLocation': {'latitu...
28 {'placeVisit': {'location': {'latitudeE7': 353...
29 {'activitySegment': {'startLocation': {'latitu...
30 {'placeVisit': {'location': {'latitudeE7': 353...
31 {'activitySegment': {'startLocation': {'latitu...
32 {'placeVisit': {'location': {'latitudeE7': 353...
33 {'activitySegment': {'startLocation': {'latitu...
34 {'placeVisit': {'location': {'latitudeE7': 353...
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。