In Python 2 use:
>>> df.groupby(df.index / 3).mean()
col1
0 2.0
1 0.5
More Related Contents:
- Binning a column with Python Pandas
- Mapping ranges of values in pandas dataframe [duplicate]
- Binning a column with pandas
- Why does the following code cant get value of n_fold = 1?
- How to change the order of DataFrame columns?
- Filter dataframe rows if value in column is in a set list of values [duplicate]
- Add missing dates to pandas dataframe
- Converting a Pandas GroupBy output from Series to DataFrame
- Pandas: sum DataFrame rows for given columns
- datetime dtypes in pandas read_csv
- Pandas DataFrame: replace all values in a column, based on condition
- Pandas – Slice large dataframe into chunks
- Calculate average of every x rows in a table and create new table
- How to check if any value is NaN in a Pandas DataFrame
- Removing prefix from column names in Pandas
- Python Pandas replicate rows in dataframe
- Can’t drop NAN with dropna in pandas
- How to plot two columns of a pandas data frame using points
- which is faster for load: pickle or hdf5 in python
- How to read a list of parquet files from S3 as a pandas dataframe using pyarrow?
- Return multiple columns from pandas apply()
- Python Pandas – Merge based on substring in string
- Filling in date gaps in MultiIndex Pandas Dataframe
- append dictionary to data frame
- Find unique values in a Pandas dataframe, irrespective of row or column location
- Python: How to drop a row whose particular column is empty/NaN?
- Combine Pandas data frame column values into new column
- How to upload a CSV file in FastAPI and convert it into a Pandas Dataframe?
- DataFrame object has no attribute append
- Python Pandas : pandas.to_datetime() is switching day & month when day is less than 13