-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Conversation
pandas/_libs/tslibs/timestamps.pyx
Outdated
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() |
There was a problem hiding this comment.
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
pandas/_libs/tslibs/timestamps.pyx
Outdated
_dt = datetime(self.year, self.month, self.day, | ||
self.hour, self.minute, self.second, | ||
self.microsecond, self.tzinfo, fold=self.fold) |
There was a problem hiding this comment.
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.. 😄)
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
pandas/_libs/tslibs/timestamps.pyx
Outdated
_dt = dt.time(self.hour, self.minute, self.second, | ||
self.microsecond, self.tzinfo, fold=self.fold) | ||
return _dt |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @DeaMariaLeon !
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal * Added tests and updated code_checks.sh * Corrected time and timetz * Corrected Timestamp.time and timetz
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal * Added tests and updated code_checks.sh * Corrected time and timetz * Corrected Timestamp.time and timetz
* Examples Timestamp.time, timetuple, timetz, to_datetime64, toordinal * Added tests and updated code_checks.sh * Corrected time and timetz * Corrected Timestamp.time and timetz
Towards #37875
Partially fixing #53668