I'm doing a calculation on a DataFrame and then want to scale the results. I keep getting errors about expecting a 2D array and to "Reshape your data either using array.reshape(-1, 1) if your data has a single feature"
import pandas as pd
df = pd.DataFrame({'a': ['aaa', 'bbb', 'ccc'],
'b': [1, 2, 3],
'c': [4, 5, 6],
'd': [7, 8, 9]})
df.set_index('a', inplace=True)
series = df[['b', 'c']].sum(axis=1).div(df[['b', 'd']].sum(axis=1), axis=0)
scaler = StandardScaler()
series.values = scaler.fit_transform(series.values)
I'm expecting a resulting DataFrame or Series with the original index intact and a single column of scaled results.