-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: DatetimeIndex.set_freq #20886
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
Comments
I think this should also include deprecating setting the I've prepared some code to implement these changes in case the decision was made to add this in #20772, as I didn't want to be the person holding up 0.23.0. Just have some minor renaming changes to make ( |
yes that would be nice @jschendel |
To reiterate my reason to hold back on this on the previous PR:
So to summarize: I just don't see the need to have this, doing |
@jorisvandenbossche not having this is just inconsistent. We have an immutable index, having any writebable properties is just plain wrong. |
Did you read my explanation of why this does not solve inconsistency at all?
Please explain why this is "plain wrong", I give a whole bunch of arguments, you just "plain wrong". It's not because the index values are immutable that certain of its attributes cannot be mutable ( Personally I don't really care about this (it is such a minor use-case, but exactly for that I don't think it is worth a new method), but it annoys me you dismiss my attempt to discussion with just "plain wrong". |
because setting an attribute in an immutable object is wrong - not sure how much more clear than that for names we have set_name which returns a new object one does not expect immutable objects to be mutated |
Yes, but we also can set the
|
We set the name directly in several places in the docs as well. What's the
(user-facing) issue caused by that?
…On Tue, May 1, 2018 at 7:40 AM, Joris Van den Bossche < ***@***.***> wrote:
for names we have set_name which returns a new object
Yes, but we also can set the name object directly. This works fine. And
personally, if I need this, I use that instead of the set_names method:
idx = idx.set_names('name')
vsidx.name = 'name'
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#20886 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIlblT3wpgnxHcgIuyg_ACBQSKQmtks5tuFe5gaJpZM4Ts93t>
.
|
setting attributes on immutable objects is just a bad pattern. there is no reason to extend / expand this. we have been pro-actively removing this attribute access, e.g. Finally, having methods allows one to return a new object and chain things. Setting attributes generallly is pretty much an anti-pattern, similar to the |
But all those examples do change the representation of the index data or change the index data itself. Setting the Having a property (with getter/setter functionality under the hood) is certainly pythonic compared to explicit There are two reasons to have a
For the second bullet point: I personally don't think it is needed (it is in any case not needed technically), similarly as changing the name does not need to return a new object (so you can do eg And for the first, the question is then the question we always ask ourselves if somebody opens an issue for a new method / functionality: is this functionality worth it for adding yet another method to the already crowded namespace? |
leftover from #20772
IIUC, the proposal is for
datetime_index.set_freq(new_freq)
to be an alternative todatetimeindex.freq = new_freq
(please correct me if I'm wrong).This would also apply to TimedeltaIndex.
The text was updated successfully, but these errors were encountered: