Note

Pandas (49) 본문

Pandas

Pandas (49)

알 수 없는 사용자 2022. 9. 15. 18:50
728x90

 How to filter every nth row in a dataframe?

# Input
df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv')

# Solution
print(df.iloc[::20, :][['Manufacturer', 'Model', 'Type']])

# output
  Manufacturer    Model     Type
0         Acura  Integra    Small
20     Chrysler  LeBaron  Compact
40        Honda  Prelude   Sporty
60      Mercury   Cougar  Midsize
80       Subaru   Loyale    Small

'Pandas' 카테고리의 다른 글

Pandas (51)  (1) 2022.09.17
Pandas (50)  (0) 2022.09.16
Pandas (48)  (0) 2022.09.14
Pandas (47)  (0) 2022.09.13
Pandas (46)  (0) 2022.09.12
Comments