Skip to content

Commit

Permalink
Check object for name/dtype attributes rather than type
Browse files Browse the repository at this point in the history
This is to help cudf, which handles things like Series.name as an
attribute rather than as a computed property.  This seems reasonable
generally.
  • Loading branch information
mrocklin committed Mar 18, 2019
1 parent aea27d1 commit adfd0dd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dask/dataframe/utils.py
Expand Up @@ -514,24 +514,24 @@ def is_dataframe_like(df):
""" Looks like a Pandas DataFrame """
typ = type(df)
return (all(hasattr(typ, name)
for name in ('dtypes', 'groupby', 'head', 'merge', 'mean'))
and not
for name in ('groupby', 'head', 'merge', 'mean')) and
all(hasattr(df, name) for name in ('dtypes',)) and not
any(hasattr(typ, name)
for name in ('value_counts', 'dtype')))


def is_series_like(s):
""" Looks like a Pandas Series """
typ = type(s)
return (all(hasattr(typ, name)
for name in ('name', 'dtype', 'groupby', 'head', 'mean'))
and 'index' not in typ.__name__.lower())
return (all(hasattr(typ, name) for name in ('groupby', 'head', 'mean')) and
all(hasattr(s, name) for name in ('dtype', 'name')) and
'index' not in typ.__name__.lower())


def is_index_like(s):
""" Looks like a Pandas Index """
typ = type(s)
return (all(hasattr(typ, name) for name in ('name', 'dtype'))
return (all(hasattr(s, name) for name in ('name', 'dtype'))
and 'index' in typ.__name__.lower())


Expand Down

0 comments on commit adfd0dd

Please sign in to comment.