plydata.one_table_verbs.create¶
-
class
plydata.one_table_verbs.create(*args, **kwargs)[source]¶ Create DataFrame with columns
Similar to
define, but it drops the existing columns.- Parameters
- data
dataframe, optional Useful when not using the
>>operator.- args
strs,tuples, optional Expressions or
(name, expression)pairs. This should be used when the name is not a valid python variable name. The expression should be of typestror an interable with the same number of elements as the dataframe.- kwargs
dict, optional {name: expression}pairs.- kwargs
dict, optional {name: expression}pairs.
- data
Examples
>>> import pandas as pd >>> df = pd.DataFrame({'x': [1, 2, 3]}) >>> df >> create(x_sq='x**2') x_sq 0 1 1 4 2 9 >>> df >> create(('x*2', 'x*2'), ('x*3', 'x*3'), x_cubed='x**3') x*2 x*3 x_cubed 0 2 3 1 1 4 6 8 2 6 9 27 >>> df >> create('x*4') x*4 0 4 1 8 2 12