Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Surprising behavior of DataFrame.replace #3582
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 |
cpcloud
referenced
this issue
May 13, 2013
Merged
ENH: add regex functionality to DataFrame.replace #3584
|
yes, I would |
|
just realized the |
|
@cploud close this too? |
|
Not just yet. Need to submit 0.12 pr. |
cpcloud commentedMay 11, 2013
This seems a bit surprising:
Does this have to do with padding?