Skip to content

TST: add tests for using .at() with DateTime indexes #48286

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 6 commits into from
Aug 31, 2022
Merged

TST: add tests for using .at() with DateTime indexes #48286

merged 6 commits into from
Aug 31, 2022

Conversation

nealxm
Copy link
Contributor

@nealxm nealxm commented Aug 27, 2022

added the tests described in issue #29709 but I feel like more around this subject could be written. let me know what you think! thank you for your time

@@ -97,6 +99,18 @@ def test_at_setitem_categorical_missing(self):

tm.assert_frame_equal(df, expected)

@pytest.mark.parametrize("row", (to_datetime("2019-01-01"), "2019-01-01"))
Copy link
Member

Choose a reason for hiding this comment

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

Could you please check the whole DataFrame with tm.assert_frame_equal and use Timestamp() instead too?

@pytest.mark.parametrize("row", (to_datetime("2019-01-01"), "2019-01-01"))
def test_at_datetime_index(self, row):
df = DataFrame(
data=[[1] * 2] * 2,
Copy link
Member

Choose a reason for hiding this comment

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

Passing data=1 should work here. The dimensions are defined by columns and index in this case

@pep8speaks
Copy link

pep8speaks commented Aug 28, 2022

Hello @nealxm! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-08-31 02:15:58 UTC

@nealxm
Copy link
Contributor Author

nealxm commented Aug 28, 2022

Hi Patrick, thanks so much for the feedback hopefully this is better. Just aside, I did not ignore your note on creating df just with passing data=1 I just removed the the explicit column names to make comparing two full data frames a bit easier so the dimensions were no longer given.

@@ -97,6 +99,24 @@ def test_at_setitem_categorical_missing(self):

tm.assert_frame_equal(df, expected)

@pytest.mark.parametrize("row",
(Timestamp("2019-01-01"),
to_datetime("2019-01-01"),
Copy link
Member

Choose a reason for hiding this comment

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

this is the same as the Timestamp argument

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this can be removed in favor of the Timestamp param above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies I misunderstood earlier. I thought you were suggesting using Timestamp() as another test to be added

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sorry. This wasn't clear on my side

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype labels Aug 29, 2022
@nealxm
Copy link
Contributor Author

nealxm commented Aug 31, 2022

hello! I never left a comment after I fixed what your comments were referring to, just wanted to update you that I took care of it.

… the class since it was not put in the right place before
@mroeschke mroeschke added this to the 1.6 milestone Aug 31, 2022
@mroeschke mroeschke merged commit 3f9c042 into pandas-dev:main Aug 31, 2022
@mroeschke
Copy link
Member

Thanks @nealxm

@nealxm nealxm deleted the neal-dev-29709 branch August 31, 2022 16:30
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
* add tests outlined in GH29709

* fix styling error caught by github actions

* made changes based on suggestions from patrick

* fix pep8 mistakes

* remove usage of to_datetime()

* fix error in pre-commit checks also move my new test to the bottom of the class since it was not put in the right place before

Co-authored-by: Neal Muppidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.at indexing with date string promotes column type, while indexing with datetime casts value
5 participants