make new columns Flashcards
1
Q
Assign new columns to a DataFrame, returning a new object (a copy) with the new columns added to the original ones. Existing columns that are re-assigned will be overwritten
A
df.assign(Area=lambda df: df.Length*df.Height)
2
Q
Add single column.
A
df[‘Volume’] = df.Length*df.Height*df.Depth
3
Q
Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating quantile membership for each data point.
A
pandas.qcut(x, q, labels=None, retbins=False, precision=3)
4
Q
Trim values at input thresholds
A
clip(lower=-10,upper=10)