I want to filter a DataFrame using a condition which is passing a function I made. This function will return True or False.
But I get this exception:
TypeError: cannot convert the series to <class 'float'>
This is my code:
def filter():
inicio = time.time()
df = pd.read_csv('data_base.csv')
nrows = df.shape[0]
for i in range(nrows).__reversed__():
coincidencias = df[
(df['Fecha'] == df.loc[i]['Fecha']) &
(df['Mercado'] == df.loc[i]['Mercado']) &
(df['Local'].str.contains(main_word(df.loc[i]['Local']), case=False)) &
(df['Visitante'].str.contains(main_word(df.loc[i]['Visitante']), case=False)) &
----> (is_there_surebet(df['Contenido'], df.loc[i]['Contenido'])) <----
].dropna()
if coincidencias.shape[0] > 1:
print(coincidencias)
df = df.drop([i])
fin = time.time()
print(fin-inicio)
The line between arrows is the one that cause the exeption. Let me know if the is_there_surebet function is necessary to fix the problem, but I think it won't be the case.