Advertisement
Dodma

Untitled

Jul 10th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. from pymystem3 import Mystem
  2. m = Mystem()
  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:
  8. return 'школьная столовая'
  9. if 'гоу' in row:
  10. return 'школьная столовая'
  11. if 'при' in row:
  12. return 'школьная столовая'
  13. if 'столовая для персонала' in row:
  14. return 'школьная столовая'
  15. if 'гбоу' in row:
  16. return 'школьная столовая'
  17. if 'шк' in row:
  18. return 'школьная столовая'
  19. if 'столовая при колледже' in row:
  20. return 'школьная столовая'
  21. if 'комбинат' in row:
  22. return 'школьная столовая'
  23. rests['object_name_clean'] = rests['object_name_lemma'].apply(categorizer)
  24. rests.head(20)
  25.  
  26.  
  27. KeyError Traceback (most recent call last)
  28. /opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
  29. 2896 try:
  30. -> 2897 return self._engine.get_loc(key)
  31. 2898 except KeyError:
  32.  
  33. pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  34.  
  35. pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  36.  
  37. pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  38.  
  39. pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  40.  
  41. KeyError: 'object_name_clean'
  42.  
  43. During handling of the above exception, another exception occurred:
  44.  
  45. KeyError Traceback (most recent call last)
  46. <ipython-input-18-08dd595a6994> in <module>
  47. 3 rests['object_name_lemma'] = rests['object_name'].apply(m.lemmatize)
  48. 4 from collections import Counter
  49. ----> 5 print(Counter(rests['object_name_clean'].sum()))
  50. 6 def categorizer(row):
  51. 7 if 'школа' in row:
  52.  
  53. /opt/conda/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
  54. 2978 if self.columns.nlevels > 1:
  55. 2979 return self._getitem_multilevel(key)
  56. -> 2980 indexer = self.columns.get_loc(key)
  57. 2981 if is_integer(indexer):
  58. 2982 indexer = [indexer]
  59.  
  60. /opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
  61. 2897 return self._engine.get_loc(key)
  62. 2898 except KeyError:
  63. -> 2899 return self._engine.get_loc(self._maybe_cast_indexer(key))
  64. 2900 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
  65. 2901 if indexer.ndim > 1 or indexer.size > 1:
  66.  
  67. pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  68.  
  69. pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
  70.  
  71. pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  72.  
  73. pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  74.  
  75. KeyError: 'object_name_clean'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement