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

Pandas fix #99

Merged
merged 14 commits into from
Jul 31, 2024
Merged

Pandas fix #99

merged 14 commits into from
Jul 31, 2024

Conversation

Pizza2Pizza
Copy link
Collaborator

@Pizza2Pizza Pizza2Pizza commented Jul 15, 2024

Updated versions of pandas, pint and pint-pandas:

pandas = "^2.0"
pint = "^0.24"
pint-pandas = "0.6"

Updated functions due to internal changes of pint-pandas that distinguish between pandas Series with object data type and one with pint units


📚 Documentation preview 📚: https://portfolyo--99.org.readthedocs.build/en/99/

@Pizza2Pizza Pizza2Pizza linked an issue Jul 15, 2024 that may be closed by this pull request
# Convert all values to same unit.
units = fr.values[0].units
magnitudes = [v.to(units).magnitude for v in fr.values]
return pd.Series(magnitudes, fr.index, dtype=f"pint[{units}]")
Copy link
Owner

Choose a reason for hiding this comment

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

There is actually a much easier way to convert a series of objects into a pint-series, if possible:

image

Copy link
Owner

Choose a reason for hiding this comment

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

@@ -9,7 +9,7 @@


# Allowed frequencies.
ALLOWED_FREQUENCIES_DOCS = "'15T' (=quarterhour), 'H', 'D', 'MS', 'QS' (or 'QS-FEB', 'QS-MAR', etc.), or 'AS' (or 'AS-FEB', 'AS-MAR', etc.)"
ALLOWED_FREQUENCIES_DOCS = "'15T' (=quarterhour), 'H', 'D', 'MS', 'QS' (or 'QS-FEB', 'QS-MAR', etc.), or 'YS' (or 'AS-FEB', 'AS-MAR', etc.)"
Copy link
Owner

Choose a reason for hiding this comment

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

YS-FEB, YS-MAR

@@ -71,7 +71,7 @@ Frequency

The index must have a frequency (``fr.index.freq``) and it must be a valid frequency. To check validity of the frequency, one may use ``portfolyo.assert_freq_valid()``. The following abbreviations are used by ``pandas`` and throughout this package:

* ``15T``: quarterhourly;
* ``15min``: quarterhourly;
* ``H``: hourly;
Copy link
Owner

Choose a reason for hiding this comment

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

should this be lowercase?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oi, you meant 'H'
also, yes

The frequency at which to resample. 'AS' for year, 'QS' for quarter, 'MS'
(default) for month, 'D for day', 'H' for hour, '15T' for quarterhour.
The frequency at which to resample. 'YS' for year, 'QS' for quarter, 'MS'
(default) for month, 'D for day', 'H' for hour, '15min' for quarterhour.
Copy link
Owner

Choose a reason for hiding this comment

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

@Pizza2Pizza: should 'H' be 'h'?

@@ -251,8 +251,8 @@ def longest(*freqs: str) -> str:

Examples
--------
>>> freq.longest('MS', 'H', 'AS', 'D')
'AS'
>>> freq.longest('MS', 'H', 'YS', 'D')
Copy link
Owner

Choose a reason for hiding this comment

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

@@ -231,7 +231,7 @@ def shortest(*freqs: str) -> str:

Examples
--------
>>> freq.shortest('MS', 'H', 'AS', 'D')
>>> freq.shortest('MS', 'H', 'YS', 'D')
Copy link
Owner

Choose a reason for hiding this comment

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

@rwijtvliet rwijtvliet merged commit b8febaa into develop Jul 31, 2024
13 checks passed
@rwijtvliet rwijtvliet deleted the pandas_fix branch July 31, 2024 13:21
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.

[bug] update pandas version
2 participants