It is necessary to collect from excel files, for example: enter image description here

certain lines

import pandas as pd import numpy as np text = 'коробк' fn = r'c:\Users\ALEX\Downloads\Книга1.xlsx' df = pd.read_excel(fn) # df.loc[df.isnull()] = 1 df[df.ix[:,2].str.lower().str.contains(text.lower())] 

DeprecationWarning: .ix is ​​deprecated. Please use .location for label based indexing or .iloc for positional indexing

using .iloc

  df.iloc[df.ix[:,2].str.lower().str.contains(text.lower())] 

next mistake

ValueError: cannot index with NA / NaN values

  • In the warning, everything seems to be clearly described and indicated what to do ... What are your difficulties? - MaxU

1 answer 1

The .str.contains (pattern) method expects a regular expression as the first parameter.

* has a special meaning in regular expressions - 0 или более повторений предыдущего символа .

In the line '*коробк*' - an asterisk in the first place and there is nothing in front of it, hence the error:

error: nothing to repeat at position 0

You can simply remove the asterisks:

 text = 'коробк'