A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/9297 below:

DataFrame.eval, inplace option · Issue #9297 · pandas-dev/pandas · GitHub

Building off of #9229, it's generally much better to create new dataframes rather than to modify existing ones. It's both more chainable and less prone to the bugs/errors associated with mutable state.

So it seems to me that a saner API design would be to make assignment operations with eval/query return a new frame rather than modify the existing one, i.e., df.eval('x = y ** 2') should be equivalent to df.assign(x = lambda df: df.y ** 2) (as currently defined in #9239).

In my experience, something like df.query('x = 0') is more likely intended to be equivalent to df.query('x == 0') rather than df['x'] = 0, which has the unfortunate effect of also modifying the original data. In fact, I have made this exact mistake before -- and apparently others have as well (see #8664).

Thoughts? The query/eval syntax is marked as experimental, so I think we have the freedom to change this.

CC @TomAugspurger @cpcloud @jreback


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4