I am creating a function to place a value within specific ranges. It works fine until I place it inside a function.
Merged_Data = MFR.merge(Rangos_FactorRiesgo_tmp, how='cross')
print(Merged_Data)
# fr= Merged_Data.query(f"{i}.between({i}_LimInf, {i}_LimSup)")
def Intervalos(df_result):
resultado =df_result.query(df_result['x'].between(df_result['y'], df_result['z']))
return resultado
Merged_Data.apply(Intervalos)
The error is AttributeError: 'Series' object has no attribute 'query'
I am creating this function so that based on the resulting dataframes, obtain a final value
Merged_Data.apply
will apply Intervalos
to each row of the DataFrame, and the row will be passed to the function as a Series. So it makes sense. I'm not sure what you're trying to achieve, but I think you can just do Intervalos(Merged_Data)
instead of the apply thing.