diff --git a/.github/workflows/ngr.yml b/.github/workflows/ngr.yml index 0a57501..cc03de9 100644 --- a/.github/workflows/ngr.yml +++ b/.github/workflows/ngr.yml @@ -8,12 +8,14 @@ on: - '.github/workflows/ngr.yml' - 'pueblo/ngr/**' - 'tests/ngr/**' + - 'pyproject.toml' push: branches: [ main ] paths: - '.github/workflows/ngr.yml' - 'pueblo/ngr/**' - 'tests/ngr/**' + - 'pyproject.toml' # Allow job to be triggered manually. workflow_dispatch: diff --git a/CHANGES.md b/CHANGES.md index 9e79f66..0c9a9c9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # Changes for pueblo ## Unreleased +- Testing: Add `pueblo.testing.pandas.{makeTimeDataFrame,makeMixedDataFrame}`. + They have been removed from `pandas._testing` on behalf of pandas 2.2.0. ## 2024-01-19 v0.0.6 - Packaging: Fix `MANIFEST.in` diff --git a/pueblo/testing/dataframe.py b/pueblo/testing/dataframe.py index 6ba9cb9..3e13d71 100644 --- a/pueblo/testing/dataframe.py +++ b/pueblo/testing/dataframe.py @@ -5,9 +5,10 @@ from inspect import signature import pandas as pd -from pandas._testing import makeMixedDataFrame, makeTimeDataFrame from pandas.io.formats.info import DataFrameInfo +from pueblo.testing.pandas import makeMixedDataFrame, makeTimeDataFrame + logger = logging.getLogger(__name__) diff --git a/pueblo/testing/pandas.py b/pueblo/testing/pandas.py new file mode 100644 index 0000000..af4d0ad --- /dev/null +++ b/pueblo/testing/pandas.py @@ -0,0 +1,39 @@ +import typing as t + +import numpy as np +import pandas as pd + + +def makeTimeDataFrame(nper=None, freq="B") -> pd.DataFrame: + """ + pandas 2.2.0 removed `pandas._testing.makeTimeDataFrame`. + + TST/CLN: Remove makeTime methods + https://github.com/pandas-dev/pandas/pull/56264 + + :param nper: + :param freq: + :return: + """ + return pd.DataFrame( + np.random.default_rng(2).standard_normal((nper, 4)), + columns=pd.Index(list("ABCD"), dtype=object), + index=pd.date_range("2000-01-01", periods=nper, freq=freq), + ) + + +def getMixedTypeDict() -> t.Tuple[pd.Index, t.Dict[str, t.Any]]: + index = pd.Index(["a", "b", "c", "d", "e"]) + + data = { + "A": [0.0, 1.0, 2.0, 3.0, 4.0], + "B": [0.0, 1.0, 0.0, 1.0, 0.0], + "C": ["foo1", "foo2", "foo3", "foo4", "foo5"], + "D": pd.bdate_range("1/1/2009", periods=5), + } + + return index, data + + +def makeMixedDataFrame() -> pd.DataFrame: + return pd.DataFrame(getMixedTypeDict()[1]) diff --git a/pyproject.toml b/pyproject.toml index 9df3117..aff3442 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,7 @@ dataframe = [ "dask", "numpy", "pandas", + "pyarrow", ] develop = [ "black[jupyter]<24", @@ -258,7 +259,7 @@ format = [ # Configure Ruff not to auto-fix (remove!): # Ignore unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001). { cmd = "ruff --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 ." }, - { cmd = "pyproject-fmt pyproject.toml" }, + { cmd = "pyproject-fmt --keep-full-version pyproject.toml" }, ] lint = [