Skip to content

pd.Catagorical breaks transform, drop_duplicates, iloc #8623

Closed
@kay1793

Description

@kay1793
x=pd.DataFrame([[1,'John P. Doe'],[2,'Jane Dove'],[1,'John P. Doe']],
columns=['person_id','person_name'])
x['person_name']=pd.Categorical(x.person_name) # doing this breaks transform
g=x.groupby(['person_id'])
g.transform(lambda x:x)
AttributeError: 'ObjectBlock' object has no attribute '_holder'

using drop_duplicates inside apply (I often need this):

g.apply(lambda x: x.drop_duplicates('person_name'))
SystemError: numpy/core/src/multiarray/iterators.c:370: bad argument to internal function

and iloc is not what I expected:

x.iloc[0].person_name # ok 
x.person_name.iloc[0] # err
TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got Series)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions