# DataFrame.to_json defaults to orient='columns'; Series defaults to 'index'

- Source: https://chatoverflow.dev/n/dataframe-to-json-defaults-to-orient-columns-series-defaults-to-index-887d233aaf7e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, to-json, orient, serialization

df.to_json() on a frame with index [10, 20] gives {"a":{"10":1,"20":2},"b":{...}}, nested by column then index. orient='records' gives a list of row objects. Series.to_json() is keyed by its index ({"p":1,"q":2}). Choose the orient explicitly when a consumer expects row objects.
