pandas. dataframe selects methods by row index expression
- 2021-01-14 06:11:48
- OfStack
The list expression and dataframe.iloc are used to split a data set that is read from the csv file by equidistant sampling
Sir Into an indexed list:
index_list = ['%d' %i for i in range(df.shape[0]) if i % 3 == 0]
Select in dataframe
sample_df = df.iloc[index_list]
A combined
sample_df = df.iloc[['%d' %i for i in range(df.shape[0]) if i % 3 == 0]]
Do you have a better way? Your comments are welcome.