-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Surprising behavior of DataFrame.replace #3582
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
could be a bug |
also no doc for the first parameter of this method, will submit a pr for that... |
also if u have time: I think we need clarification in the main docs on usage of when to use filter, replace, select, update, lookup I also don't think there is an example of filter anywhere |
np, not sure if will be done 2day, trying to work out the regex replace on frames and just wanted to note this strangeness when i was looking at one of the simplest possible cases of replacement in an object block |
@jreback A quick glance at |
@cpcloud I think replace is somewhere |
ah yes, |
Wow, this was worrying, but fortunately |
@jreback seems the magic is already in |
@jreback The "bug" here is that when you call df.replace({'a': 'b'}) the column |
you want this equivalent to df.replace('a','b') ? |
yes, is that ok? |
let me take a look a little later was always fuzzy on this anyhow are there tests for this usage anyhow ? |
There are tests. However, the # get the test frame
from pandas.tests.test_frame import _tsframe as df
from numpy.testing import assert_array_equal
res = df.replace({'A': nan}, method='pad', axis=1)
assert_array_equal(df, res) # replace == identity function here |
I think it makes sense to not have automatic interpolation by default so, if say then make @cpcloud why don't you put up the PR when you are ready (as this would be an easy change anyhow) |
okay. kicking tires a bit right now (added 12 new tests so far); adding the regex functionality is proving to be quite a bit more involved than i thought, but i have a much better understanding (although not complete) of |
yes, I would |
just realized the |
@cploud close this too? |
Not just yet. Need to submit 0.12 pr. |
This seems a bit surprising:
Does this have to do with padding?
The text was updated successfully, but these errors were encountered: