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
ENH: Make DataFrame.insert more flexible #34365
Comments
If I understand, this new insert would be exactly like assign ( in assign, you can pass a callable or dict of callables), the only this that assign miss is the location of the columns ( and the inplace option but not sure it is a good idea) |
so you can see I am bascially -1 on any additional functionaility for |
@topper-123 I think some of the functionalities you mention would be interesting, but I also wondering why we would make |
@jreback , yeah I don't like the inplace param in general either, though in cases where it makes sense to keep I'm positive to keep it (e.g. for performance reasons). I do think piping is a great concept when transforming data and should be encouraged. I would like insert to have
The point of this would be to make insertion based on label location possible. Currently only insertion by integer location is possible. insertion by label location is more robust and easier to understand at a glance IMO. The proposed parameter names could maybe be improved, and I would idelly just have one parameter, but that couldn't be combined with insertion points before/after a label, I think.
This is so we can do simpler and excellent The above functionality could do things that the current
There's a large overlap between wrt
|
DataFrame.insert
is very inflexible today and can not really be used in pipes. I'd like to do several changes to the method:value
, so the new values can be computed from existing column values.value
, so the several columns can be inserted simultaneously,insert_after
andinsert_before
parameters to allow label-based insertion location.loc
to the aftervalue
and let it have a default value of None, i.e. insert the new column at the end of the frame if location is not specified.DataFrame.assign
. It's functionality would be covered by the changedDataFrame.insert
method.The above change would allow us to be quite flexible when creating new columns in pipes. For example we could do
The above is obviously quite a large change. It could be discussed if it would be better make it a new method instead of changing an existing one...
The text was updated successfully, but these errors were encountered: