I've been scratching my head all morning trying to understand why the following doesn't seem to work. The idea here is that if there is no column provided, run 1 set of code and if there is, then run another.
Let's say the value of df just holds 1 value = 'A'
def function_name(df, col):
if col == None:
df = df.str.lower()
else:
df[col] = df[col].str.lower()
function_name(df, None)
Expected Results: 'a'
Current Results: 'A'
If I was to run function_name(df, 'A')
:
Expected Results: 'a'
Current Results: 'a'
Ideally when running the function, since None was passed in it should return whatever commands I passed through but currently, it's acting as if nothing is happening. When I debug by printing it, I can see that the code is doing the 'stuff' but the function itself isn't resulting in whatever commands was run. Any thoughts?
Aucun commentaire:
Enregistrer un commentaire