plydata.helper_verbs.rename_all¶
-
class
plydata.helper_verbs.
rename_all
(*args, **kwargs)[source]¶ Rename all columns
- Parameters
- data
dataframe
, optional Useful when not using the
>>
operator.- functions
callable()
Useful when not using the
>>
operator.- args
tuple
Arguments to the functions. The arguments are pass to all functions.
- kwargs
dict
Keyword arguments to the functions. The keyword arguments are passed to all functions.
- data
Examples
>>> import pandas as pd >>> import numpy as np >>> from plydata import * >>> df = pd.DataFrame({ ... 'alpha': list('aaabbb'), ... 'beta': list('babruq'), ... 'theta': list('cdecde'), ... 'x': [1, 2, 3, 4, 5, 6], ... 'y': [6, 5, 4, 3, 2, 1], ... 'z': [7, 9, 11, 8, 10, 12] ... })
Rename all columns uppercase
>>> df >> rename_all(str.upper) ALPHA BETA THETA X Y Z 0 a b c 1 6 7 1 a a d 2 5 9 2 a b e 3 4 11 3 b r c 4 3 8 4 b u d 5 2 10 5 b q e 6 1 12
Group columns are not renamed
>>> df >> group_by('beta') >> rename_all(str.upper) groups: ['beta'] ALPHA beta THETA X Y Z 0 a b c 1 6 7 1 a a d 2 5 9 2 a b e 3 4 11 3 b r c 4 3 8 4 b u d 5 2 10 5 b q e 6 1 12