Skip to content

TST: Added test to check that the freqstr attribute of the index is p… #34572

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

Merged
merged 2 commits into from Jun 4, 2020
Merged

TST: Added test to check that the freqstr attribute of the index is p… #34572

merged 2 commits into from Jun 4, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jun 4, 2020

…reserved after a shift operation. Run black and flake8.

…reserved after a shift operation. Run black and flake8.
@pytest.mark.parametrize("periods", [1, 2, 3, 4])
def test_shift_preserve_freqstr(self, periods):
# GH#21275
data = list(range(0, periods))
Copy link
Member

Choose a reason for hiding this comment

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

You can pass a range directly to the DataFrame constructor so could just be range(periods)

)
assert str(np.dtype(result)) == "int64"
assert result.index.freqstr == "H"
tm.assert_series_equal(result, expected)
Copy link
Member

Choose a reason for hiding this comment

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

I think assert_series_equal should be enough here since it'll check the index frequencies and dtypes

@dsaxton dsaxton added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype labels Jun 4, 2020
@ghost ghost requested a review from dsaxton June 4, 2020 16:42
@jreback jreback added the Frequency DateOffsets label Jun 4, 2020
@jreback jreback added this to the 1.1 milestone Jun 4, 2020
@jreback jreback merged commit 4a6ba1a into pandas-dev:master Jun 4, 2020
@jreback
Copy link
Contributor

jreback commented Jun 4, 2020

thanks @KD-dev-lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Frequency DateOffsets Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shift does not always preserve freqstr if series contains only one or two elements
2 participants