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

Toplevelfunctions #84

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
test-output.xml
cover/

# Translations
Expand Down Expand Up @@ -160,3 +161,4 @@ cython_debug/
.issues/
.DS_Store
test.xlsx

30 changes: 30 additions & 0 deletions docs/core/toplevel.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. |_| unicode:: 0xA0
:trim:

===============
Top-level tools
===============

Some tools for working with ``pandas.Series``, ``pandas.DataFrame``, ``portfolyo.PfLine`` and ``portfolyo.PfState`` objects are available at the root of the package. They are concisely listed below.

----------------------
Work on pandas objects
----------------------

* ``portfolyo.asfreq_avg()`` Changes the frequency of a Series or DataFrame with "averagable" data. See :doc:`this page<../specialized_topics/resampling>` for more information.

* ``portfolyo.asfreq_sum()`` Changes the frequency of a Series or DataFrame with "summable" data. See :doc:`this page<../specialized_topics/resampling>` for more information.

* ``portfolyo.wavg()`` Calculates weighted average of a Series or DataFrame.

* ``portfolyo.standardize()`` Ensures/asserts a Series or DataFrame follows necessary rules to initialize PfLine with.

-------------------------
Work on portfolyo objects
-------------------------

* ``portfolyo.concat()`` Concatenates PfLines into one PfLine.

* ``portfolyo.plot_pfstates()`` Plots several PfStates in one figure.


3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Contents
core/pfline
core/pfstate
core/interoperability
core/toplevel

.. toctree::
:maxdepth: 1
Expand All @@ -94,4 +95,4 @@ Contents
:maxdepth: 2
:caption: Full reference

full_reference
full_reference
2 changes: 1 addition & 1 deletion docs/specialized_topics/resampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ The reason for the higher price in the previous example, is that, there, the pri
Resampling with ``portfolyo``
-----------------------------

When changing the frequency of a ``PfLine`` or ``PfState`` object, the considerations above are automatically taken into account. If you are in the situation of having to change the frequency of a ``pandas.Series`` or ``DataFrame`` with a ``DatetimeIndex``, however, the relevant functions are also available at the ``portfolyo.tools.changefreq`` module.
When changing the frequency of a ``PfLine`` or ``PfState`` object, the considerations above are automatically taken into account when using the ``.asfreq()`` method. If you are in the situation of having to change the frequency of a ``pandas.Series`` or ``DataFrame`` with a ``DatetimeIndex``, however, the relevant functions are also available at the package root, as the ``portfolyo.asfreq_avg()`` and ``portfolyo.asfreq_sum()`` functions.
309 changes: 196 additions & 113 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions portfolyo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
"""Package to analyse and manipulate timeseries related to power and gas offtake portfolios."""

from . import _version, dev, tools
from . import _version, dev, testing, tools
from .core import extendpandas # extend functionalty of pandas
from .core import suppresswarnings
from .core.shared.plot import plot_pfstates
from .core.pfline import Kind, PfLine, Structure, create
from .core.pfstate import PfState
from .core.shared.concat import general as concat
from .core.shared.plot import plot_pfstates
from .prices.hedge import hedge
from .prices.utils import is_peak_hour
from .tools.changefreq import averagable as asfreq_avg
from .tools.changefreq import summable as asfreq_sum
from .tools.changeyear import characterize_index, map_frame_to_year
from .tools.freq import FREQUENCIES
from .tools.standardize import frame as standardize
from .tools.tzone import force_agnostic, force_aware
from .tools.unit import Q_, ureg, Unit
from .tools.unit import Q_, Unit, ureg
from .tools.wavg import general as wavg
from .core.shared.concat import general as concat

# from .core.shared.concat import general as concat

Expand All @@ -27,4 +29,4 @@
suppresswarnings.apply()

__version__ = _version.get_versions()["version"]
__all__ = ["tools", "dev", "PfLine", "PfState"]
__all__ = ["tools", "dev", "testing", "PfLine", "PfState"]
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "BSD-3"
readme = "README.rst"

[tool.poetry.dependencies]
python = ">=3.10"
python = "^3.10"
pandas = "~2.0" # pandas 2.1.0 doesn't play nice with pint-pandas. Update when new pint-pandas version is released (>0.5)
matplotlib = "^3.7.2"
pint = "0.19.2"
Expand Down Expand Up @@ -41,10 +41,10 @@ sphinx-rtd-theme = "^1.3.0"
insegel = "^1.3.1"
nbsphinx = "^0.9.3"
pandoc = "^2.3"
pip-tools = "^7.4.1"
IPython = "^8.23.0"



[tool.poetry.group.dev.dependencies]
flake8 = "^6.1.0"
black = "^23.7.0"
Expand Down
1 change: 0 additions & 1 deletion test-output.xml

This file was deleted.

Loading