Python pandas apply function if a column value is not NULL

后端 未结 4 700
面向向阳花
面向向阳花 2021-02-01 03:00

I have a dataframe (in Python 2.7, pandas 0.15.0):

df=
       A    B               C
0    NaN   11             NaN
1    two  NaN  [\'foo\', \'bar\']
2  three   3         


        
4条回答
  •  情话喂你
    2021-02-01 03:39

    I had a column contained lists and NaNs. So, the next one worked for me.

    df.C.map(lambda x: my_func(x) if type(x) == list else x)
    

提交回复
热议问题