-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: support .strftime for datetimelikes (closes #10086) #10110
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
Conversation
|
this works for needs tests for the same |
|
that makes sense I've added to both |
|
pls add strftime to API.rst |
pandas/tseries/index.py
Outdated
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.
hmm, not to make this more complicated, but maybe move to tseries/base/DatelikeOps (new mixin), that both DatetimeIndex/PeriodIndex, but NOT TimedeltaIndex inherit from.
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 thought about something like that too, good idea for code reuse! Will update shortly
|
@jreback it's updated |
|
@jreback I added a mini section to |
doc/source/basics.rst
Outdated
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.
maybe be explict and say that this is a string
|
can you update for comments. also related to #10442. I want this method to be the 'primary' date-string formatting (though copy your example that you added to basics.rst and put in 0.17.0 (in a separate section, maybe datetime-string formatting or somesuch) |
|
@jreback updated according to your comments except for one thing: I couldn't actually find an invalid formatting string that would cause |
doc/source/basics.rst
Outdated
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 u add a reference to the standard library docs for the strftime format here
doc/source/whatsnew/v0.17.0.txt
Outdated
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 think this all needs to be indented 2 spaces (to form a sub-block)
|
We also have a |
|
@jorisvandenbossche sure I'll check |
pandas/tseries/period.py
Outdated
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.
put the if on the outside (and lambdas on the inside), then check is only done once
|
@jorisvandenbossche this calls |
|
@jreback reordered the |
|
ok, lgtm. ping when green. |
|
sure will do |
doc/source/basics.rst
Outdated
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.
you can use :meth:Series.dt.strftime`` here as well, then it makes the link to the doc page
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.
although that is maybe not that important here as it is exactly the same as standard library
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.
sure will do
8b3456c to
c9b9ad8
Compare
|
@jorisvandenbossche @jreback updated to return |
6c49a7e to
b09aacc
Compare
|
@jorisvandenbossche @jreback it's green now, please take a look |
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.
change back. we don't use np.testing.* directly
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.
@jreback I changed it because assert_numpy_array_equal() actually would fail in some of the testing environments. It seems like a problem with the older numpy version (1.8.x)
what should I change it to 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.
ahh, you are not comparing numpy arrays (they are actually a list and an array), use exp = np.asarray(....) and I think it will work, you can also try tm.assert_almost_equal(...)
scratch that first part, use tm.assert_almost_equal; I though you were comparing the output of .strftime which was an np.array
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.
ah cool I think tm.assert_almost_equal works, thanks! will update shortly
|
@mortada couple of comments. ping when green. |
|
@jreback updated, please take a look |
|
thanks! |
closes #10086