why the & does not work? (python, pandas)

  pandas, python

I need to do an inventory with a filter that tells me if I have what I need, but for example the height or width I need to add 0.2 to it. I tried this code but when I did the test using & it gives me this error.

    import pandas as pd

ruta = "C:UsersWindows 10 ProDesktopcurso"

df = pd.read_excel(ruta + "libro1.xlsx")

print(df)

tipo = str(input("Que tipo de vidrio es?"))
ancho = float(input("Cuanto es de ancho?"))
espesor = float(input("Cuanto es de espesor?"))
alto = float(input("Cuanto es de alto?"))

print(df[df['Tipo'].str.contains(tipo)] & [df['Alto']>= alto + 0.2] & [df['Ancho']>= ancho + 0.2] & [df['Espesor'] == espesor])


  Lote      Tipo  Alto  Ancho  Espesor
0     1     Claro  0.60    1.2        3
1     2    Espejo  0.70    1.5        4
2     3  Laminado  0.40    1.7        5
3     4     Claro  0.25    1.9        6
4     5    Espejo  0.80    1.5        7
5     6     Claro  1.20    1.3        3
Que tipo de vidrio es?Espejo
Cuanto es de ancho?1.3
Cuanto es de espesor?4
Cuanto es de alto?0.5
Traceback (most recent call last):
  File "c:/Users/Windows 10 Pro/Desktop/curso/PRUEBA3.PY", line 14, in <module>
    print(df[df['Tipo'].str.contains(tipo)] & [df['Alto']>= alto + 0.2] & [df['Ancho']>= ancho + 0.2] & [df['Espesor'] == espesor])
  File "D:Documentosanacondalibsite-packagespandascoreopscommon.py", line 65, in new_method
    return method(self, other)
  File "D:Documentosanacondalibsite-packagespandascorearraylike.py", line 59, in __and__
    return self._logical_method(other, operator.and_)
  File "D:Documentosanacondalibsite-packagespandascoreframe.py", line 5980, in _arith_method
    self, other = ops.align_method_FRAME(self, other, axis, flex=True, level=None)
  File "D:Documentosanacondalibsite-packagespandascoreops__init__.py", line 258, in align_method_FRAME
    raise ValueError(
ValueError: Unable to coerce list of <class 'pandas.core.series.Series'> to Series/DataFrame
PS C:UsersWindows 10 ProDesktopcurso> 

Source: Python Questions

LEAVE A COMMENT