Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clib.conversion._to_numpy: Add tests for pyarrow.array with date32/date64 dtype #3609

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seisman
Copy link
Member

@seisman seisman commented Nov 10, 2024

Description of proposed changes

Add tests for pyarrow.array with date64/date32 dtype.

These two types can be converted directly to numpy datetime64 with correct date units, as shown below.

In [1]: from datetime import datetime, date

In [2]: import numpy as np

In [3]: import pyarrow as pa

In [4]: x = pa.array([datetime(2012, 1, 1), date(2013, 1, 1)], type=pa.date32())

In [5]: x
Out[5]:
<pyarrow.lib.Date32Array object at 0x7f7142b70c40>
[
  2012-01-01,
  2013-01-01
]

In [6]: np.ascontiguousarray(x)
Out[6]: array(['2012-01-01', '2013-01-01'], dtype='datetime64[D]')

In [7]: x = pa.array([datetime(2012, 1, 1), date(2013, 1, 1)], type=pa.date64())

In [8]: x
Out[8]:
<pyarrow.lib.Date64Array object at 0x7f726ffb8ca0>
[
  2012-01-01,
  2013-01-01
]

In [9]: np.ascontiguousarray(x)
Out[9]:
array(['2012-01-01T00:00:00.000', '2013-01-01T00:00:00.000'],
      dtype='datetime64[ms]')

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. labels Nov 10, 2024
@seisman seisman added this to the 0.14.0 milestone Nov 10, 2024
@seisman seisman force-pushed the to_numpy/pyarrow_date32_date64 branch from 0174a49 to 795796d Compare November 10, 2024 14:12
@weiji14 weiji14 changed the title clib.conversion._to_numpy: Add tests for pyarrow.array with date32/da64 dtype clib.conversion._to_numpy: Add tests for pyarrow.array with date32/date64 dtype Nov 11, 2024
@michaelgrund michaelgrund added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final review call This PR requires final review and approval from a second reviewer maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants