Apply
Apply to perform a whole operation on a column
In [116]: frame = Dataframe (Np.random.randn (4, 3), columns=list (' BDE '), index=[' Utah ', ' Ohio ', ' Texas ', ' Oregon '])
In [117]: Frame
out[117]:
b d e
Utah -0.029638 1.081563 1.280300
Ohio 0.647747 0.831136-1.549481
Texas 0.513416-0.884417 0.195343
oregon-0.485454-0.477388- 0.309548 in
[118]: F = lambda X:x.max ()-x.min () in
[119]: Frame.apply (f)
out[119]:
b 1.133201
d 1.965980
e 2.829781
Dtype:float64
Applymap
Applymap the conversion of each element in a Dataframe
In [click]: Format = lambda x: '%.2f '% x in
[121]: Frame.applymap (format)
out[121]:
b d e
Utah -0.03 1.08 1.28
Ohio 0.65 0.83 -1.55
Texas 0.51 -0.88 0.20
Oregon -0.49 -0.48 -0.31
Map
Applymap the conversion of each element in a series
in [122]: frame[' e '].map (format) out[122]: Utah 1.28 Ohio-1.55 Texas 0.20-Orego n-0.31 Name:e, Dtype:object