Peter Moore
Peter Moore

Reputation: 2096

Resizing a Dataframe

In Pandas; how can you resample a number of points into a smaller number sample. So making this

df = pd.DataFrame(np.random.randint(10, size=(10000)))]

into say the mean values represented in 1000 points of data.

Similar to df.resample("M").mean() but for discrete 10 point intervals.

Upvotes: 0

Views: 351

Answers (1)

ansev
ansev

Reputation: 30930

You could do:

df.groupby(np.arange(len(df)) // 10).mean()

If RangeIndex:

df.index // 10

Upvotes: 1

Related Questions