BAC*_*C83 3 python indexing slice dataframe pandas
我有一个14行的周期数据帧,即每条记录有14行数据(均值,sdev等),我想为每条记录重复提取第2,第4,第7和第9行(14行) ).我的代码是:
Mean_df = df.iloc[[1,3,6,8]::14,:].copy()
这不起作用
TypeError: cannot do slice indexing on <class 'pandas.core.indexes.range.RangeIndex'> with these indexers [[1, 3, 6, 8]] of <class 'list'>
我从这里获得了代码的帮助,这对我来说非常有用,但不是多行选择 - Pandas每隔n行
我可以提取几个不同的切片并组合,但感觉可能有更优雅的解决方案.
有任何想法吗?