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

TST: Test pivot_table() with categorical data #28803

Merged
merged 7 commits into from Oct 12, 2019

Conversation

ryankarlos
Copy link
Contributor

@ryankarlos ryankarlos force-pushed the Test-PivotTable-Categoricaldata branch from 44d09f9 to 3d485d2 Compare October 6, 2019 03:38
@ryankarlos
Copy link
Contributor Author

@jorisvandenbossche @jschendel Just had a go at this - let me know if any changes required

@@ -2554,3 +2554,38 @@ def test_margin_normalize(self):
names=["A", "B"],
)
tm.assert_frame_equal(result, expected)

def test_pivot_with_categorical(self):
# gh-21370
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this near def test_categorical_margins_category(self, observed) also if you can accept the observed fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also use the ordered_fixture instead of using ordered=True.

Copy link
Contributor Author

@ryankarlos ryankarlos Oct 7, 2019

Choose a reason for hiding this comment

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

@topper-123 thanks, just added and pushed latest changes

@jreback jreback added Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Oct 6, 2019
@ryankarlos ryankarlos force-pushed the Test-PivotTable-Categoricaldata branch from 8495a98 to f19e1bf Compare October 7, 2019 20:28
@ryankarlos
Copy link
Contributor Author

ryankarlos commented Oct 7, 2019

Don't know why CI is failing - not sure error is related to my PR

[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/16dbc4a2-96e5-4986-aa53-46b5a447d609.sh
pytest -m "single and not slow and not network" -n 1 -s --strict --durations=10 --junitxml=test-data-single.xml pandas
Traceback (most recent call last):
  File "/home/vsts/miniconda3/envs/pandas-dev/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 58, in main
    config = _prepareconfig(args, plugins)
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 182, in _prepareconfig
    config = get_config()
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 153, in get_config
    pluginmanager.import_plugin(spec)
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 522, in import_plugin
    __import__(importspec)
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/tmpdir.py", line 25, in <module>
    class TempPathFactory(object):
  File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/tmpdir.py", line 35, in TempPathFactory
    lambda p: Path(os.path.abspath(six.text_type(p)))
TypeError: attrib() got an unexpected keyword argument 'convert'
##[error]Bash exited with code '1'.
##[section]Finishing: Test

@@ -1656,6 +1656,49 @@ def test_categorical_margins_category(self, observed):
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True)
tm.assert_frame_equal(table, expected)

def test_pivot_with_categorical(self, observed, ordered_fixture):
# gh-21370
idx = [np.nan, "low", "high", "low", np.nan]
Copy link
Contributor

Choose a reason for hiding this comment

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

you are not using observed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jreback Do you mean pass as keyword arg to pivot_table() ? Ive just pushed changes

@jreback jreback added this to the 1.0 milestone Oct 12, 2019
@jreback jreback merged commit 56b2fd8 into pandas-dev:master Oct 12, 2019
@jreback
Copy link
Contributor

jreback commented Oct 12, 2019

thanks @ryankarlos

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: add additional test cases for pivot_table with categorical data
3 participants