Skip to content

Commit 2ac4015

Browse files
Merge pull request pandas-dev#11826 from proinsias/pandas.core.frame
DOC: Add example to pandas.DataFrame.applymap
2 parents a050a33 + 83ab0ca commit 2ac4015

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/core/frame.py

+16
Original file line numberDiff line numberDiff line change
@@ -4138,6 +4138,22 @@ def applymap(self, func):
41384138
func : function
41394139
Python function, returns a single value from a single value
41404140
4141+
Examples
4142+
--------
4143+
4144+
>>> df = pd.DataFrame(np.random.randn(3, 3))
4145+
>>> df
4146+
0 1 2
4147+
0 -0.029638 1.081563 1.280300
4148+
1 0.647747 0.831136 -1.549481
4149+
2 0.513416 -0.884417 0.195343
4150+
>>> df = df.applymap(lambda x: '%.2f' % x)
4151+
>>> df
4152+
0 1 2
4153+
0 -0.03 1.08 1.28
4154+
1 0.65 0.83 -1.55
4155+
2 0.51 -0.88 0.20
4156+
41414157
Returns
41424158
-------
41434159
applied : DataFrame

0 commit comments

Comments
 (0)