Categories
Python Answers

How to easily share a sample dataframe using df.to_dict() with Python Pandas?

Spread the love

To easily share a sample dataframe using df.to_dict() with Python Pandas, we can split a dataframe with 'split' with calling to_dict.

For instance, we write

import plotly.express as px
df = px.data.iris().head(10)
df.to_dict('split')

to call to_dict on our dataframe with 'split' to return a data frame that has some of the rows that’s in the data frame.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *