How to open excel file in Polars dataframe?
Question:
I am a python pandas user but recently found about polars dataframe and it seems quite promising and blazingly fast. I am not able to find a way to open an excel file in polars. Polars is happily reading csv
, json
, etc. but not excel.
I am extensive user of excel files in pandas and I want to try using polars. I have many sheets in excel that pandas automatically read. How can I do same with polars?
What am I missing?
Answers:
This is more of a workaround than a real answer, but you can read it into pandas and then convert it to a polars dataframe.
import polars as pl
import pandas as pd
df = pd.read_excel(...)
df_pl = pl.DataFrame(df)
You could, however, make a feature request to the Apache Arrow community to support excel files.
Polars now has a read_excel
method, as of this PR!
https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_excel.html
You should be able to just do:
import polars as pl
df = pl.read_excel("file.xlsx")
I am a python pandas user but recently found about polars dataframe and it seems quite promising and blazingly fast. I am not able to find a way to open an excel file in polars. Polars is happily reading csv
, json
, etc. but not excel.
I am extensive user of excel files in pandas and I want to try using polars. I have many sheets in excel that pandas automatically read. How can I do same with polars?
What am I missing?
This is more of a workaround than a real answer, but you can read it into pandas and then convert it to a polars dataframe.
import polars as pl
import pandas as pd
df = pd.read_excel(...)
df_pl = pl.DataFrame(df)
You could, however, make a feature request to the Apache Arrow community to support excel files.
Polars now has a read_excel
method, as of this PR!
https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_excel.html
You should be able to just do:
import polars as pl
df = pl.read_excel("file.xlsx")