Skip to content

Commit

Permalink
TST: Added test for frequency retention in categorical constructor (p…
Browse files Browse the repository at this point in the history
…andas-dev#46779)

* Added test for github issue pandas-dev#33830 to test that categorical was preserving DateTimeIndex freq attribute

* Added an additional test for value_counts preserving frequency

* Modified tests in test_constructors.py to pass the pre-commit check

* Removed tests from test_constructors that were not needed

* Moved categorical freq retention test to pandas/tests/arrays/categorical/

Co-authored-by: Brian Gollop <bgollop@umich.edu>
  • Loading branch information
2 people authored and yehoshuadimarsky committed Jul 13, 2022
1 parent 7db7564 commit 405da95
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pandas/tests/arrays/categorical/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,3 +759,14 @@ def test_constructor_datetime64_non_nano(self):

cat = Categorical(values, categories=categories)
assert (cat == values).all()

def test_constructor_preserves_freq(self):
# GH33830 freq retention in categorical
dti = date_range("2016-01-01", periods=5)

expected = dti.freq

cat = Categorical(dti)
result = cat.categories.freq

assert expected == result

0 comments on commit 405da95

Please sign in to comment.