def test_groupby_reduce(self): data = Dataset({'xy': (['x', 'y'], np.random.randn(3, 4)), 'xonly': ('x', np.random.randn(3)), 'yonly': ('y', np.random.randn(4)), 'letters': ('y', ['a', 'a', 'b', 'b'])}) expected = data.mean('y') actual = data.groupby('x').mean() self.assertDatasetAllClose(expected, actual) actual = data.groupby('x').mean('y') self.assertDatasetAllClose(expected, actual) expected = Dataset({'xy': data['xy'].groupby('letters').mean(), 'xonly': data['xonly'].mean(), 'yonly': data['yonly'].groupby('letters').mean()}) actual = data.groupby('letters').mean() self.assertDatasetAllClose(expected, actual)