'Function to check numeric columns for anomalies Python, pandas

DataFrame from SQL. I would like to get a list of data, which contains : not numeric values less than 0 duplicates empty rows in a column So, what I have got:

num_col = uniq_order_status

def basic_check(df, name):
"""Add new column for each check"""
for i in name:
df\[i + "\_check_if_empty"\] = df.apply(lambda x: \[df.check.isnan()\])
df\[i + "\_check_if_not_number"\] = df.apply(lambda x: re.match('^0-9.$', str(x\[i\])), axis = 1) #"/\\D+/"-any non digit
df\[i + "\_check_if_negative"\] = df.apply(lambda x: (df\[i\] \< 0, axis = 1)
df\[i + "\_check_duplicates"\] = df.apply(lambda x: (df.duplicated(), axis = 1))
return df

And I need to get something like: create new column "_check_if_empty" if column has no value. Someone can help with my deal? When i try function with DF - i get bunch of Errors there: Data frame has no attribute "check" Data frame has no attribute "apply"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source