79623033

Date: 2025-05-15 09:47:28
Score: 3.5
Natty:
Report link

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

df[col_name] not in range(18,121) was wrong, as @Panagiotis Kanavos pointed out. A simpler method if you're not df['single'].between 18 and 120.all():`

In addition, if df['single'].isnull(): was the wrong value. .any() can be utilized.

Snippet:

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

def single_check(single):
    if df['single'].isnull().any():
        print("Missing values")
    
    if not df['single'].between(18, 120).all():
        print("Range error")
    else:
        print("Data is correct")

You can pass a variable as a argument in a function.

single_check(df['hCurrAge'])

Reasons:
  • Blacklisted phrase (1): how do i
  • Blacklisted phrase (1): I want to know
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Panagiotis
  • Low reputation (0.5):
Posted by: Adios Gringo