Skip to content

Resolution madness#21

Open
suvayu wants to merge 43 commits into
mainfrom
tests
Open

Resolution madness#21
suvayu wants to merge 43 commits into
mainfrom
tests

Conversation

@suvayu

@suvayu suvayu commented Jan 30, 2025

Copy link
Copy Markdown
Contributor
  • low_res_datetime
  • make package pipeable
  • add tests

Comment thread arrow_expts/spine/dbmap.py Outdated

You can check the available ranges with `pd.Timestamp.min` and `pd.Timestamp.max`.
"""
period_parts = re.search(r'^([0-9]+) *(.*)$', freq).groups()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for match, if no match returns None. Should raise a error message then

Comment thread arrow_expts/spine/dbmap.py Outdated
"""
period_parts = re.search(r'^([0-9]+) *(.*)$', freq).groups()
if len(period_parts) != 2:
raise ValueError("Can't analyze period \"{period}\".")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message is not specific. Say what is the problem, like couldn't separate number from unit, etc.

Comment thread arrow_expts/spine/dbmap.py Outdated
period_parts = re.search(r'^([0-9]+) *(.*)$', freq).groups()
if len(period_parts) != 2:
raise ValueError("Can't analyze period \"{period}\".")
number_str, unit = period_parts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe merge with above and catch ValeuError

Comment thread arrow_expts/spine/dbmap.py Outdated
freq_pd = pd.Timedelta(freq_np)
#print(f"freq_pd: {freq_pd}")

date_array = np.arange(start_date_np, start_date_np + periods * freq_pd, freq_pd)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at pd.date_range, maybe it has the same behaviour, but code would be simpler.

suvayu added 20 commits April 4, 2025 12:02
pandas.DateOffset is similar to relative delta
Arrays in the absense of "value_type" default to "float" (as per the
docs), here the data is text string, not convertible to a number.
- minute is abbreviated as min
- convert freq to int before passing to DateOffset
Refactor the module w/ conditional imports to use Pydantic for schema
generation (invoked as `python -m models.py json-blob-schema.json`),
but use plain Python definitions when used as a module.

Update the JSON schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant