Normalizar columnas en pandas dataFrame2
import pandas as pd
df = pd.DataFrame(
columns=['term', '2002', '2003', '2004', '2005'],
data=[['climate', 1, 10, 1, 14],
['global', 12, 11, 2, 12],
['nuclear', 10, 1, 0, 4], ])
normalized = df.select_dtypes('int').apply(lambda x: x / sum(x))
df = df.merge(
right=normalized,
left_index=True,
right_index=True,
suffixes=['', '_norm']
)
Worried Wren