snowflake.snowpark.modin.plugin.extensions.resample_overrides.Resampler.size¶
- Resampler.size() Union[DataFrame, Series] [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/resample_overrides.py#L518-L534)¶
Compute group sizes.
- Parameters:
None –
- Returns:
Number of rows in each group as a Series if
as_index
is True or aDataFrame
ifas_index
is False.- Return type:
Examples
For Series:
>>> lst1 = pd.date_range('2020-01-01', periods=4, freq='1D') >>> ser1 = pd.Series([1, 2, 3, 4], index=lst1) >>> ser1 2020-01-01 1 2020-01-02 2 2020-01-03 3 2020-01-04 4 Freq: None, dtype: int64
>>> ser1.resample('2D').size() 2020-01-01 2 2020-01-03 2 Freq: None, dtype: int64
>>> lst2 = pd.date_range('2020-01-01', periods=4, freq='S') >>> ser2 = pd.Series([1, 2, np.nan, 4], index=lst2) >>> ser2 2020-01-01 00:00:00 1.0 2020-01-01 00:00:01 2.0 2020-01-01 00:00:02 NaN 2020-01-01 00:00:03 4.0 Freq: None, dtype: float64
>>> ser2.resample('2S').size() 2020-01-01 00:00:00 2 2020-01-01 00:00:02 2 Freq: None, dtype: int64
For DataFrame:
>>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]] >>> df = pd.DataFrame(data, ... columns=["a", "b", "c"], ... index=pd.date_range('2020-01-01', periods=4, freq='1D')) >>> df a b c 2020-01-01 1 8 2 2020-01-02 1 2 5 2020-01-03 2 5 8 2020-01-04 2 6 9
>>> df.resample('2D').size() 2020-01-01 2 2020-01-03 2 Freq: None, dtype: int64