Skip to content

Fixes for Pandas 2 support#742

Merged
pquentin merged 49 commits intoelastic:mainfrom
bartbroere:prepare-for-pandas-2
Feb 4, 2025
Merged

Fixes for Pandas 2 support#742
pquentin merged 49 commits intoelastic:mainfrom
bartbroere:prepare-for-pandas-2

Conversation

@bartbroere
Copy link
Copy Markdown
Contributor

I have started to work on the Pandas 2 support again. Locally I'm testing with an environment that already uses Pandas 2, and these are the changes that were required to get some tests fixed.

The objective is to not break the Pandas 1.5 support, so these should be safe to merge. Where it seemed useful I added some line comments with the reasoning behind the change.

Some more PRs might follow later this week. Once all tests pass on Pandas 2, we can update the CI to include it in the test matrix.

@pquentin
Copy link
Copy Markdown
Member

Thank you for this! Will review later this week.

The objective is to not break the Pandas 1.5 support, so these should be safe to merge. Where it seemed useful I added some line comments with the reasoning behind the change.

It's OK to break Pandas 1.5 support in a new release if it brings Pandas 2.0 support.

@bartbroere bartbroere changed the title Several fixes for the tests to prepare for Pandas 2 support Fixes for Pandas 2 support Dec 19, 2024
@pquentin
Copy link
Copy Markdown
Member

pquentin commented Jan 6, 2025

buildkite test this please

@pquentin
Copy link
Copy Markdown
Member

buildkite test this please

Comment thread eland/dataframe.py Outdated
@bartbroere
Copy link
Copy Markdown
Contributor Author

@pquentin I addressed all open comments, and I think the pull request is ready for re-review. Feel free to re-open comments if something needs to be changed.

@bartbroere bartbroere requested a review from pquentin February 3, 2025 10:46
@pquentin
Copy link
Copy Markdown
Member

pquentin commented Feb 3, 2025

buildkite test this please

Copy link
Copy Markdown
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! I left two nitpicks, also lint is failing.

Comment thread eland/dataframe.py
Comment thread eland/dataframe.py
Comment thread eland/etl.py Outdated
Comment thread tests/notebook/test_demo_notebook.ipynb
@pquentin
Copy link
Copy Markdown
Member

pquentin commented Feb 4, 2025

buildkite test this please

Copy link
Copy Markdown
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM. 🚀

@pquentin pquentin merged commit 75c57b0 into elastic:main Feb 4, 2025
github-actions Bot pushed a commit that referenced this pull request Feb 12, 2025
* Fix test setup to match pandas 2.0 demands

* Use the now deprecated _append method

(Better solution might exist)

* Deal with numeric_only being removed in metrics test

* Skip mad metric for other pandas versions

* Account for differences between pandas versions in describe methods

* Run black

* Check Pandas version first

* Mirror behaviour of installed Pandas version when running value_counts

* Allow passing arguments to the individual asserters

* Fix for method _construct_axes_from_arguments no longer existing

* Skip mad metric if it does not exist

* Account for pandas 2.0 timestamp default behaviour

* Deal with empty vs other inferred data types

* Account for default datetime precision change

* Run Black

* Solution for differences in inferred_type only

* Fix csv and json issues

* Skip two doctests

* Passing a set as indexer is no longer allowed

* Don't validate output where it differs between Pandas versions in the environment

* Update test matrix and packaging metadata

* Update version of Python in the docs

* Update Python version in demo notebook

* Match noxfile

* Symmetry

* Fix trailing comma in JSON

* Revert some changes in setup.py to fix building the documentation

* Revert "Revert some changes in setup.py to fix building the documentation"

This reverts commit ea98797.

* Use PANDAS_VERSION from eland.common

* Still skip the doctest, but make the output pandas 2 instead of 1

* Still skip doctest, but switch to pandas 2 output

* Prepare for pandas 3

* Reference the right column

* Ignore output in tests but switch to pandas 2 output

* Add line comment about NBVAL_IGNORE_OUTPUT

* Restore missing line and add stderr cell

* Use non-private method instead

* Fix indentation and parameter issues

* If index is not specified, and pandas 1 is present, set it to True

From pandas 2 and upwards, index is set to None by default

* Run black

* Newer version of black might have different opinions?

* Add line comment

* Remove unused import

* Add reason for ignore statement

* Add reason for skip

---------

Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
(cherry picked from commit 75c57b0)
pquentin added a commit that referenced this pull request Feb 13, 2025
* Support Pandas 2 (#742)

* Fix test setup to match pandas 2.0 demands

* Use the now deprecated _append method

(Better solution might exist)

* Deal with numeric_only being removed in metrics test

* Skip mad metric for other pandas versions

* Account for differences between pandas versions in describe methods

* Run black

* Check Pandas version first

* Mirror behaviour of installed Pandas version when running value_counts

* Allow passing arguments to the individual asserters

* Fix for method _construct_axes_from_arguments no longer existing

* Skip mad metric if it does not exist

* Account for pandas 2.0 timestamp default behaviour

* Deal with empty vs other inferred data types

* Account for default datetime precision change

* Run Black

* Solution for differences in inferred_type only

* Fix csv and json issues

* Skip two doctests

* Passing a set as indexer is no longer allowed

* Don't validate output where it differs between Pandas versions in the environment

* Update test matrix and packaging metadata

* Update version of Python in the docs

* Update Python version in demo notebook

* Match noxfile

* Symmetry

* Fix trailing comma in JSON

* Revert some changes in setup.py to fix building the documentation

* Revert "Revert some changes in setup.py to fix building the documentation"

This reverts commit ea98797.

* Use PANDAS_VERSION from eland.common

* Still skip the doctest, but make the output pandas 2 instead of 1

* Still skip doctest, but switch to pandas 2 output

* Prepare for pandas 3

* Reference the right column

* Ignore output in tests but switch to pandas 2 output

* Add line comment about NBVAL_IGNORE_OUTPUT

* Restore missing line and add stderr cell

* Use non-private method instead

* Fix indentation and parameter issues

* If index is not specified, and pandas 1 is present, set it to True

From pandas 2 and upwards, index is set to None by default

* Run black

* Newer version of black might have different opinions?

* Add line comment

* Remove unused import

* Add reason for ignore statement

* Add reason for skip

---------

Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
(cherry picked from commit 75c57b0)

* Return input_field_names as list as required by Pandas 2

---------

Co-authored-by: Bart Broere <mail@bartbroere.eu>
Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants