BUG: DataFrame/Series.transform with list and non-list dict values · Issue #40018 · pandas-dev/pandas (original) (raw)

df = pd.DataFrame({'a': [1, 2], 'b': [1, 4], 'c': [1, 4]})
print(df.transform({'b': ['sqrt', 'abs'], 'c': 'sqrt'}))
print(df['a'].transform({'b': ['sqrt', 'abs'], 'c': 'sqrt'}))

produces

     b        c
  sqrt abs    c
0  1.0   1  1.0
1  2.0   4  2.0
          b             c
       sqrt abs         a
0  1.000000   1  1.000000
1  1.414214   2  1.414214

In each case the last column label on the 2nd level should be "sqrt" and not "a" or "c".