Skip to content

[BUG] DataFrame.describe fails if no numeric columns #323

Closed
@mcobzarenco

Description

@mcobzarenco

DataFrame.describe function fails with the following when called on a
Data Frame with no numeric columns:

/usr/lib64/python2.7/site-packages/pandas/core/
frame.py(2324)describe()
2322 '25%', '50%', '75%', 'max']
2323
-> 2324 data = [tmp.count(), tmp.mean(), tmp.std(), tmp.min(),
2325 tmp.quantile(.25), tmp.median(),
2326 tmp.quantile(.75), tmp.max()]
/usr/lib64/python2.7/site-packages/pandas/core/frame.py(2361)count()
2359 frame = self
2360
-> 2361 result = DataFrame.apply(frame, Series.count,
axis=axis)
2362
2363 # what happens with empty DataFrame
/usr/lib64/python2.7/site-packages/pandas/core/frame.py(1984)apply()
1982 else:
1983 if not broadcast:
-> 1984 return self._apply_standard(func, axis)
1985 else:
1986 return self._apply_broadcast(func, axis)

/usr/lib64/python2.7/site-packages/pandas/core/frame.py(2000)_apply_standar d()

1998 results[k] = func(target[k])
1999
-> 2000 if hasattr(results.values()[0], 'iter'):
2001 result = self._constructor(data=results,
index=target.index,
2002

The problem seems to be that in the function DataFrame.describe, tmp
is empty if there are no numeric columns:

cols = self._get_numeric_columns()
tmp = self.reindex(columns=cols)

Nonetheless, Series.describe itself works on non-numeric values.

-- Marius

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions