Use .apply
to send a column of every row to a function
You can use .apply
to send a single column to a function. This is useful when
cleaning up data - converting formats, altering values etc.
|
DPT |
NAME |
ADDRESS |
TTL # |
PC |
SAL-RATE |
0 |
868 |
B J SANDIFORD |
DEPARTMENT OF CITYWIDE ADM |
12702 |
X |
$5.00 |
1 |
868 |
C A WIGFALL |
DEPARTMENT OF CITYWIDE ADM |
12702 |
X |
$5.00 |
2 |
69 |
A E A-AWOSOGBA |
HRA/DEPARTMENT OF SOCIAL S |
52311 |
A |
$51955.00 |
0 5.0
1 5.0
2 51955.0
Name: SAL-RATE, dtype: float64
|
DPT |
NAME |
ADDRESS |
TTL # |
PC |
SAL-RATE |
salary |
0 |
868 |
B J SANDIFORD |
DEPARTMENT OF CITYWIDE ADM |
12702 |
X |
$5.00 |
5.0 |
1 |
868 |
C A WIGFALL |
DEPARTMENT OF CITYWIDE ADM |
12702 |
X |
$5.00 |
5.0 |
2 |
69 |
A E A-AWOSOGBA |
HRA/DEPARTMENT OF SOCIAL S |
52311 |
A |
$51955.00 |
51955.0 |
Use .apply
with axis=1
to send every single row to a function
You can also send an entire row at a time instead of just a single column.
Use this if you need to use multiple columns to get a result.
|
height |
width |
0 |
40.0 |
10 |
1 |
20.0 |
9 |
2 |
3.4 |
4 |
0 400.0
1 180.0
2 13.6
dtype: float64
|
height |
width |
area |
0 |
40.0 |
10 |
400.0 |
1 |
20.0 |
9 |
180.0 |
2 |
3.4 |
4 |
13.6 |