Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pymystem3 import Mystem
- m = Mystem()
- rests['object_name_lemma'] = rests['object_name'].apply(m.lemmatize)
- from collections import Counter
- print(Counter(rests['object_name_clean'].sum()))
- def categorizer(row):
- if 'школа' in row:
- return 'школьная столовая'
- if 'гоу' in row:
- return 'школьная столовая'
- if 'при' in row:
- return 'школьная столовая'
- if 'столовая для персонала' in row:
- return 'школьная столовая'
- if 'гбоу' in row:
- return 'школьная столовая'
- if 'шк' in row:
- return 'школьная столовая'
- if 'столовая при колледже' in row:
- return 'школьная столовая'
- if 'комбинат' in row:
- return 'школьная столовая'
- rests['object_name_clean'] = rests['object_name_lemma'].apply(categorizer)
- rests.head(20)
- KeyError Traceback (most recent call last)
- /opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
- 2896 try:
- -> 2897 return self._engine.get_loc(key)
- 2898 except KeyError:
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
- KeyError: 'object_name_clean'
- During handling of the above exception, another exception occurred:
- KeyError Traceback (most recent call last)
- <ipython-input-18-08dd595a6994> in <module>
- 3 rests['object_name_lemma'] = rests['object_name'].apply(m.lemmatize)
- 4 from collections import Counter
- ----> 5 print(Counter(rests['object_name_clean'].sum()))
- 6 def categorizer(row):
- 7 if 'школа' in row:
- /opt/conda/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
- 2978 if self.columns.nlevels > 1:
- 2979 return self._getitem_multilevel(key)
- -> 2980 indexer = self.columns.get_loc(key)
- 2981 if is_integer(indexer):
- 2982 indexer = [indexer]
- /opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
- 2897 return self._engine.get_loc(key)
- 2898 except KeyError:
- -> 2899 return self._engine.get_loc(self._maybe_cast_indexer(key))
- 2900 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
- 2901 if indexer.ndim > 1 or indexer.size > 1:
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
- KeyError: 'object_name_clean'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement