Skip to content

Always return categorical dtype when get() is called with a mapping #317

@frankenjoe

Description

@frankenjoe

Example:

db = audformat.Database('db')
db.schemes['text'] = audformat.Scheme(dtype='str')
db['misc'] = audformat.MiscTable(
    pd.Index(
      ['a', 'b', 'c'],
      name='speaker',
      dtype='string',
    )
)
db['misc']['text'] = audformat.Column(scheme_id='text')
db['misc']['text'].set(['A', 'B', 'C'])

db.schemes['scheme'] = audformat.Scheme('str', labels='misc')
db['table'] = audformat.MiscTable(audformat.filewise_index(['f1', 'f2', 'f3']))
db['table']['column'] = audformat.Column(scheme_id='scheme')
db['table']['column'].set(['a', 'b', 'c'])

db['table']['column'].get(map='text').dtype
category

and if 'text' contains None, we get:

db['misc']['text'].set(['A', 'B', None])
db['table']['column'].get(map='text').dtype
object

But in both cases we would expect string category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions