G
G
Grigory Dudnikov2016-01-26 12:38:31
Python
Grigory Dudnikov, 2016-01-26 12:38:31

How to group a DataFrame by n values ​​in pandas?

I have a DataFrame in pandas (python 3) and it is grouped by dates with

df.set_index('Datetime').groupby(pd.TimeGrouper('M'))

Tell me, is it possible to somehow use df.groupby()or another approach to group data by N values?
For example, do I need to process a group of the first 100 values ​​first, then the second, and so on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman_Kh, 2016-01-26
@1win1

Add another column to the DataFrame, with the value 1 for the first 100 rows, 2 for the next 100 rows, and so on. And then make groupby on this column.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question