Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'Series' object has no attribute 'query'

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading