Advertisement
MarVish

Untitled

May 28th, 2022
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #считаем количество слов в названии
  2. rest['words'] = rest['object_name'].str.split().str.len()
  3.  
  4. def replacing(row):
  5.     if row['words'] > 1:
  6.         # удаляем "приставки"
  7.         row['object_name'].replace(to_replace = replace_list,
  8.                             value = '',
  9.                             regex = True,
  10.                             inplace=True
  11.                            )
  12.         # удаляем пробел перед названием
  13.         row['object_name'] = row['object_name'].str.lstrip()
  14.  
  15.  
  16.  
  17. rest['object_name'] = rest.apply(replacing, axis=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement