In this tutorial, we will show you how to store a pandas data frame as a JSONL file.
First, let’s create a simple pandas data frame:
import pandas as pd df = pd.DataFrame({'Col_A':[1,2,3,4,5], 'Col_B':['a','b','c','d','e']}) df

Now, let’s convert it to a JSON format and save it as .jsonl
file
df_jsonl = df.to_json(orient="records", lines=True) with open("data.jsonl", "w") as f: f.write(df_jsonl)
As we can see, we created a new file called data.jsonl
:
