I have a spark dataframe
that contain 4 columns:
(col_1, col_2, col_3, col_4) ==> (String, String, Int, Int)
In the data, sometime col_3
is empty, for example:
col_1|col_2|col_3|col_4
col_1|col_2||col_4
I want to return a new dataframe
that contain just 3 columns, after testing columns 3 and 4:
if col_3
is empty return col_4
else return col_3
To solve it i did this:
>>>
>>> def calculcolumn(col_3, col_4):
... if (col_3 is None ):
... return col_4
... else:
... return col_3
...
>>>
>>> calculcolumn( ,12)
File "<stdin>", line 1
calculcolumn( ,12)
^
SyntaxError: invalid syntax
>>>
But it throws SyntaxError
, how can I resolve it?