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

DOC: Fixing EX01 - Added examples #53725

Merged
merged 8 commits into from
Jun 21, 2023
Merged

Conversation

DeaMariaLeon
Copy link
Member

Towards #37875

Partially fixing #53668

@DeaMariaLeon DeaMariaLeon removed the request for review from MarcoGorelli June 19, 2023 14:35
@DeaMariaLeon DeaMariaLeon added this to the 2.1 milestone Jun 19, 2023
Comment on lines 1555 to 1564
try:
_dt = datetime(self.year, self.month, self.day,
self.hour, self.minute, self.second,
self.microsecond, self.tzinfo, fold=self.fold)
except ValueError as err:
raise NotImplementedError(
"time not yet supported on Timestamps which "
"are outside the range of Python's standard library. "
) from err
return _dt.time()
Copy link
Member

Choose a reason for hiding this comment

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

can we construct a time object directly, where time is imported from datetime? then it shouldn't be necessary to have try/except, it should always pass

Comment on lines 1603 to 1605
_dt = datetime(self.year, self.month, self.day,
self.hour, self.minute, self.second,
self.microsecond, self.tzinfo, fold=self.fold)
Copy link
Member

Choose a reason for hiding this comment

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

same as above (can we use time directly?)

(unrelated, but I'm really confused about what the use of this method is - time zones make little sense if there aren't dates associated with them.. 😄)

Copy link
Member Author

Choose a reason for hiding this comment

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

I must be missing something but I get: AttributeError: 'datetime.time' object has no attribute 'timetz'
I checked the docs too. So, isn't timetz a datetime method?

_dt = dt.time(self.hour, self.minute, self.second,
self.microsecond, self.tzinfo)
return _dt

Copy link
Member Author

Choose a reason for hiding this comment

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

@MarcoGorelli - sorry I just saw that here I'm returning dt.time, not timetz.
But should I return super().timetz instead?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there is a super().timetz method

Copy link
Member

Choose a reason for hiding this comment

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

oh wait, sorry, there is, that's why there was no definition previously

in which case, yeah, if it doesn't give incorrect results for negative dates or anything, then that looks fine

Copy link
Member

Choose a reason for hiding this comment

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

seems to work fine

In [41]: pd.Timestamp('-2000-01-01 01:00:00+01:00').timetz()
Out[41]: datetime.time(1, 0, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))

ok to just use this then, thanks for noticing!

Comment on lines 1557 to 1559
_dt = dt.time(self.hour, self.minute, self.second,
self.microsecond, self.tzinfo, fold=self.fold)
return _dt
Copy link
Member

Choose a reason for hiding this comment

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

super().time() probably works here too

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @DeaMariaLeon !

@MarcoGorelli MarcoGorelli merged commit d2664fe into pandas-dev:main Jun 21, 2023
@DeaMariaLeon DeaMariaLeon deleted the timestamps branch June 21, 2023 14:16
punndcoder28 pushed a commit to punndcoder28/pandas that referenced this pull request Jun 21, 2023
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal

* Added tests and updated code_checks.sh

* Corrected time and timetz

* Corrected Timestamp.time and timetz
canthonyscott pushed a commit to canthonyscott/pandas-anthony that referenced this pull request Jun 23, 2023
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal

* Added tests and updated code_checks.sh

* Corrected time and timetz

* Corrected Timestamp.time and timetz
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal

* Added tests and updated code_checks.sh

* Corrected time and timetz

* Corrected Timestamp.time and timetz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants