Create pystarburst dataframe from pandas dataframe

Hi,

I was going through the pystarburst API guide and trying out some data engineering stuffs. I have a specific use case to create a pystarburst dataframe from a pandas dataframe.

When I checked the CreateDataframe method it takes list and tuple only as input. I couldn’t find a way to create a pystarburst dataframe from a pandas dataframe.

Just wanted to understand if there is anyway you would suggest me to do this.

Appreciate any help. Thanks.

Hi there!

The below code should be able to help you convert between a pandas dataframe to a pystarburst dataframe.

df = pd.DataFrame(pydf.collect())
print(df)
list_of_dicts = df.to_dict(orient='records')
# print(list_of_dicts)
pydf2 = session.create_dataframe(list_of_dicts)
df2 = pd.DataFrame(pydf2.collect())
print(df2)