I do not understand this apply behavior .. pandas apply updates inplace but returns None
>>>import pandas as pd
>>>df_test = pd.Series({0: {'A', 'E'},
1: {'A', 'C', 'E', 'S'},
2: {'A', 'C', 'E'},
3: {'A', 'C', 'E', 'S'},
4: {'A', 'E'}})
>>>df_test
0 {A, E}
1 {A, S, E, C}
2 {A, C, E}
3 {A, S, E, C}
4 {A, E}
dtype: object
>>>df_test.apply(lambda x: x.add("X"))
0 None
1 None
2 None
3 None
4 None
dtype: object
but,
>>>df_test
0 {A, X, E}
1 {A, X, S, E, C}
2 {A, X, C, E}
3 {A, X, S, E, C}
4 {A, X, E}
dtype: object
so df_test is updated. but then if I do this:
>>> df_test = df_test.apply(lambda x: x.add("X"))
>>> df_test
0 None
1 None
2 None
3 None
4 None
dtype: object
what is the explanation for thisbehavior - the apply is updating the dataframe in place but returned type is None.