pandas 每隔n行 [英] Pandas every nth row

查看:85
本文介绍了 pandas 每隔n行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dataframe.resample()仅适用于时间序列数据.我找不到从非时间序列数据中获取第n行的方法.最好的方法是什么?

Dataframe.resample() works only with timeseries data. I cannot find a way of getting every nth row from non-timeseries data. What is the best method?

推荐答案

我将使用iloc,它根据整数位置并遵循常规python语法获取行/列切片.

I'd use iloc, which takes a row/column slice, both based on integer position and following normal python syntax.

df.iloc[::5, :]

这篇关于 pandas 每隔n行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆