[Python] How to pass a dataframe variable to a function in python

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a spss dataset that i'm importing into python.

    Next i want is to validate the data. I have written some function to do the same but when i pass the variable error occurs.

    Can somebody please guide me through it.

    df,meta=pyreadstat.read_sav("SL_2025.sav")

    def single_check(single):
    if df['single'].isnull():
    print("Missing values")
    if df['single'] not in range(18,121):
    print("Range error")
    else:
    print("Data is correct")


    single_check('hCurrAge')

    Here hCurrAge is a variable with values ranging from 20 to 120

    I want to know how do i pass a variable as a argument in a function

    Continue reading...

Compartilhe esta Página