Skip to content

global name 'iNaT' is not defined #9675

Closed
@samzhang111

Description

@samzhang111

Trying to perform this operation on a groupby object called clusters:

clusters.agg({'diffs': lambda x: x.quantile(.5)})

where diffs is a column of Timedelta objects.

Getting the error:

/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in aggregate(self, func_or_funcs, *args, **kwargs)
   2305                 return self._python_agg_general(func_or_funcs, *args, **kwargs)
   2306             except Exception:
-> 2307                 result = self._aggregate_named(func_or_funcs, *args, **kwargs)
   2308 
   2309             index = Index(sorted(result), name=self.grouper.names[0])

/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in _aggregate_named(self, func, *args, **kwargs)
   2392         for name, group in self:
   2393             group.name = name
-> 2394             output = func(group, *args, **kwargs)
   2395             if isinstance(output, (Series, Index, np.ndarray)):
   2396                 raise Exception('Must produce aggregated value')

<ipython-input-174-5be8bb847fd6> in <lambda>(x)
----> 1 clusters.agg({'diffs': lambda x: x.quantile(.5)})

/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in quantile(self, q)
   1264                 return _quantile(values, qs*100)
   1265 
-> 1266         return self._maybe_box(lambda values: multi(values, q), dropna=True)
   1267 
   1268     def ptp(self, axis=None, out=None):

/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in _maybe_box(self, func, dropna)
   2105 
   2106             if len(values) == 0:
-> 2107                 return boxer(iNaT)
   2108 
   2109             values = values.view('i8')

NameError: global name 'iNaT' is not defined

Looks like other references to iNaT are all tslib.iNaT.

https://github.com/pydata/pandas/blob/master/pandas/core/series.py#L2098

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