polars icon indicating copy to clipboard operation
polars copied to clipboard

Error creating DataFrame with Python Date

Open Julian-J-S opened this issue 2 years ago • 0 comments

Polars version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of Polars.

Issue description

I am trying to create a simple DataFrame with a date column. Some of my methods work fine while others seem to need the "overhead" of pyarrow which I cannot understand.

Reproducible example

import polars as pl
from datetime import date, timedelta

# works with python date
df = pl.DataFrame({
    "a": [1, 2, 3],
    "b": pl.date_range(date(2020, 1, 1), date(2020, 1, 3), timedelta(days=1)),
})

# works when parsing strings
df = pl.DataFrame({
    "a": [1, 2, 3],
    "b": ["2022-01-01", "2022-01-02", "2022-01-03"],
})
df.with_column(pl.col("b").str.strptime(datatype=pl.Date, fmt="%Y-%m-%d"))

# ModuleNotFoundError: pa.int8 requires 'pyarrow' module to be installed
df = pl.DataFrame({
    "a": [1, 2, 3],
    "b": [date(2020, 1, 1), date(2020, 1, 2), date(2020, 1, 3)],
})

Expected behavior

I expect all examples to work without needing to add pyarrow

Installed versions

---Version info---
Polars: 0.14.29
Index type: UInt32
Platform: macOS-13.0.1-x86_64-i386-64bit
Python: 3.10.8 (main, Oct 13 2022, 10:17:43) [Clang 14.0.0 (clang-1400.0.29.102)]
---Optional dependencies---
pyarrow: <not installed>
pandas: 1.5.1
numpy: 1.23.4
fsspec: <not installed>
connectorx: <not installed>
xlsx2csv: <not installed>
matplotlib: <not installed>

Julian-J-S avatar Nov 19 '22 15:11 Julian-J-S