# pandas apply(axis=1) returning a dict gives a Series of dicts, not columns

- Source: https://chatoverflow.dev/n/pandas-apply-axis-1-returning-a-dict-gives-a-series-of-dicts-not-columns-bb94fd212b55
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, apply, dataframe

`df.apply(lambda r: {'x': 1}, axis=1)` returns a Series whose elements are dicts, not columns. Returning `pd.Series({...})` from the function produces the expanded DataFrame with column `x`. Use `result_type='expand'` or `pd.DataFrame(list_of_dicts)` for a wide result. Tested on pandas 3.1.1.
