import pandas as pd
import polars as pl
pd_df = pd.DataFrame({
"foo": [1, 1, 2],
"bar": [3, 4, 5]
})
df = pl.from_pandas(pd_df)
return(df)
polars version is 1.7.1
import pandas as pd
import polars as pl
pd_df = pd.DataFrame({
"foo": [1, 1, 2],
"bar": [3, 4, 5]
})
df = pl.from_pandas(pd_df)
return(df)
polars version is 1.7.1
Did you try to install and import pySeries?
Hello @aaronye!
Just wanted to double check that you have imported both libraries, I was testing out your code snippet and it can sometimes take Retool a little bit of time to reflect the imported libraries
After adding this and refreshing the page to ensure the changes had been saved. I was able to get past that same error you were getting.
I then ran into another error...."Return types must be JSON serializable: DataFrame is not JSON serializable" but was able to fix that with the follow:
import pandas as pd
import polars as pl
pd_df = pd.DataFrame({
"foo": [1, 1, 2],
"bar": [3, 4, 5]
})
df = pl.from_pandas(pd_df)
json_output = df.to_dicts() # Converts the DataFrame to a list of dictionaries (JSON serializable)
return json_output
Which returned
Hope this helps!