nunique + TimeGrouper error
See original GitHub issueThis used to work in the past:
tmp = pd.DataFrame({
'ID': {pd.Timestamp('2015-06-05 00:00:00'): '0010100903', pd.Timestamp('2015-06-08 00:00:00'): '0010150847'},
'DATE': {pd.Timestamp('2015-06-05 00:00:00'): '2015-06-05', pd.Timestamp('2015-06-08 00:00:00'): '2015-06-08'}})
tmp.groupby(pd.TimeGrouper('D')).ID.nunique()
but now I get the obscure:
Traceback (most recent call last):
File "test.py", line 6, in <module>
tmp.groupby(pd.TimeGrouper('D')).ID.nunique()
File "/usr/lib/python3/dist-packages/pandas/core/groupby.py", line 2697, in nunique
name=self.name)
File "/usr/lib/python3/dist-packages/pandas/core/series.py", line 227, in __init__
data = SingleBlockManager(data, index, fastpath=True)
File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 3736, in __init__
ndim=1, fastpath=True)
File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 2454, in make_block
placement=placement)
File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 87, in __init__
len(self.values), len(self.mgr_locs)))
ValueError: Wrong number of items passed 2, placement implies 4
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Whats wrong with my grouping or looping? - Stack Overflow
My problem is that sometimes, even tho the conditions are met, it wrongly classifies my data. For instance group "table 5": id nnDist1...
Read more >GroupBy — pandas 0.25.0 documentation
GroupBy.sem (self[, ddof]), Compute standard error of the mean of groups, ... DataFrameGroupBy.nunique (self[, dropna]), Return DataFrame with number of ...
Read more >Source code for pandas.core.groupby
[docs] def sem(self, ddof=1): """ Compute standard error of the mean of groups, ... **kwargs): """ Provide resampling when using a TimeGrouper Return...
Read more >https://www.psych.mcgill.ca/labs/mogillab/anaconda...
_cython_agg_general(f) b = TimeGrouper(Minute(5), closed='right', label='right') g ... index=np.random.choice(dr, n)) left = ts.resample('30T').nunique() ix ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The logically equivalent:
works as intended.
yeah there were some fixes related to this, but this one didn’t take.