Polars
In [ ]:
Copied!
# Install the opendal and polars
!pip install opendal, polars
# Install the opendal and polars
!pip install opendal, polars
In [ ]:
Copied!
import polars as pl
import opendal
# Init an operator.
op = opendal.Operator("fs", root="/tmp")
# Create a DataFrame.
df = pl.DataFrame({"name": ["Alice", "Bob"], "age": [20, 30]})
print(f"df: {df}")
# Open and write the DataFrame to the file.
with op.open("test.csv", mode="wb") as file:
df.write_csv(file)
# Open and read the DataFrame from the file.
with op.open("test.csv", mode="rb") as file:
read_df = pl.read_csv(file)
print(f"read_df: {read_df}")
import polars as pl
import opendal
# Init an operator.
op = opendal.Operator("fs", root="/tmp")
# Create a DataFrame.
df = pl.DataFrame({"name": ["Alice", "Bob"], "age": [20, 30]})
print(f"df: {df}")
# Open and write the DataFrame to the file.
with op.open("test.csv", mode="wb") as file:
df.write_csv(file)
# Open and read the DataFrame from the file.
with op.open("test.csv", mode="rb") as file:
read_df = pl.read_csv(file)
print(f"read_df: {read_df}")