How can I use the apply() function for a single column?
You don't need a function at all. You can work on a whole column directly.
Example data:
>>> df = pd.DataFrame({'a': [100, 1000], 'b': [200, 2000], 'c': [300, 3000]})>>> df a b c0 100 200 3001 1000 2000 3000
Half all the values in column a
:
>>> df.a = df.a / 2>>> df a b c0 50 200 3001 500 2000 3000