python - Pandas 0.13.1 use of groupby( ) with drop_duplicates( ) or dropna ( ) -
I just updated the pandas to 0.13.1 from the previous version - happily, this opened some options for me unfortunately From, it seems that some of my data tilt codes have caused problems. I did not make any changes other than updating the panda version from 0.11.0.
The code that used to work first, and now works, is as follows:
g_pres dropdown (0) And / or
g_pres = (= 'follow', 'focal', 'std_epoch']) drop-duplicates (0) Error using any of the results:
(Previous) --------------------------- -------------------- ---------------------------- Attribute error Tracebacks (most recent call final) & lt; Ipython-input-169-5d3c7458da40 & gt; In & lt; Module & gt; () ---- & gt; 1 g_pres = g_pres.groupby (['follow', 'focal', 'std_epoch']). Dropna (0) //anaconda/lib/python2.7/site-packages/pandas/core/groupby.py __getattr __ (self, atr) 293 294 if heetter (self, boss, ether) and atr! = '_cache': - & gt; 295 returns self _Make_Enter_Activate (Entry) 296 297 Entitlement ("% R Object does not have any attribute in% r"% //anaconda/lib/python2.7/site-packages/pandas/core/groupby// _make_wrapper (auto, name) 308 "using the 'Apply' method." Format (type, name, 309 type (self) .__ name__)) - & gt; 310 Extended AttributeError (msg) 311 312f = getattr (self.obj, name) attribute error: Can not enter callable attribute 'dropna' of 'dataframe gap by object', try to use 'apply' method I have reviewed the release notes, search for the group, drop_duplicate and drop_enna, but I can not find anything to indicate this (at least for me) which The reason for this change can be that I am starting a So maybe I'm ignoring something
Does the drop_duplicates function now work for the group's dataframe? Is there a new syntax? ... is this a feature or bug?
I thought that the additional meaning of the Inasthal method meant that I had to specify something which was previously defaults, but there was no progress in the document for the relevant methods.
[ADD ADD TO EXAMPLE]
Example Input:
Follow std_epoch Focal 0 1 1 53704 51602 1 1 1 53704 51602 2 1 2 53704 51602 3 2 1 53505 5150 9 2 2 53505 51509 Example production, where I want to follow by group, std_epoch and focal - and drop the duplicate value from column '0', group-wise (in this example , This is line 2 in the input). Follow std_epoch Focal 0 1 1 53704 51602 1 1 2 53704 51602 2 2 1 53505 5150 9 3 2 2 53505 51509 < Solution: Basically, to reconsider the problem, as mentioned in my comment, I use the group to drop duplicates. Not required, I will just put it in the same line in my previous code. I am still not clear why it makes an error, where it was not before (maybe it always puts an error, although as a result, the result I was looking for!) However, I just do it in two lines I am here. To drop a duplicate:
df = df.drop_duplicates () To create a grouped object:
df = df.groupby (['column1', 'column2'])
Comments
Post a Comment