How can I skip even/odd rows while reading a csv file?

nivniv

Is there a simple way to ignore all even/odd rows when reading a csv using pandas?

I know skiprows argument in pd.read_csv but for that I'll need to know the number of rows in advance.

Chris

The pd.read_csv skiprows argument accepts a callable, so you could use a lambda function. E.g.:

df = pd.read_csv(some_path, skiprows=lambda x: x%2 == 0)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Error while reading csv file in R

분류에서Dev

Error while reading csv file in R

분류에서Dev

How can I skip objects from a JSON file if the value of a key = 0?

분류에서Dev

How can I print out the delimiter character and allow user to edit line while reading standard input?

분류에서Dev

How to skip rows in MySQL

분류에서Dev

How can I read a big CSV file without Memory exhausted?

분류에서Dev

How to not read the header row while reading csv using Scanner?

분류에서Dev

Reading in a CSV file

분류에서Dev

How can I read from a CSV file into 2 ArrayLists depending on the data type I have got in the File?

분류에서Dev

How to skip rows in Hbase Scan?

분류에서Dev

How can I store avatar(image file) through Auth/RegisterController while user registration?

분류에서Dev

While in vi how can I pull in / insert / paste the contents of another file

분류에서Dev

Importing a CSV file into postgres - skip the first line

분류에서Dev

How to skip multiple iterations in a while loop

분류에서Dev

Detect empty lines while reading from file

분류에서Dev

Random UnauthorizedAccessException while reading a file in %temp%

분류에서Dev

Wrong file path while reading from UI

분류에서Dev

Infinity loop while reading data from file

분류에서Dev

bash: Prompting for user input while reading file

분류에서Dev

.csv file reading from a specified URL

분류에서Dev

Reading a csv file into csh using awk

분류에서Dev

How do i choose where i output in a csv file

분류에서Dev

In Python, how can I update multiple rows in a DataFrame with a Series?

분류에서Dev

How can I view file header information?

분류에서Dev

How can I save the last command to a file?

분류에서Dev

How can I wait for the write of a file?

분류에서Dev

How can I copy a text file into another?

분류에서Dev

How can i replace particular characters in a file

분류에서Dev

How can I test for a file having a value?

Related 관련 기사

  1. 1

    Error while reading csv file in R

  2. 2

    Error while reading csv file in R

  3. 3

    How can I skip objects from a JSON file if the value of a key = 0?

  4. 4

    How can I print out the delimiter character and allow user to edit line while reading standard input?

  5. 5

    How to skip rows in MySQL

  6. 6

    How can I read a big CSV file without Memory exhausted?

  7. 7

    How to not read the header row while reading csv using Scanner?

  8. 8

    Reading in a CSV file

  9. 9

    How can I read from a CSV file into 2 ArrayLists depending on the data type I have got in the File?

  10. 10

    How to skip rows in Hbase Scan?

  11. 11

    How can I store avatar(image file) through Auth/RegisterController while user registration?

  12. 12

    While in vi how can I pull in / insert / paste the contents of another file

  13. 13

    Importing a CSV file into postgres - skip the first line

  14. 14

    How to skip multiple iterations in a while loop

  15. 15

    Detect empty lines while reading from file

  16. 16

    Random UnauthorizedAccessException while reading a file in %temp%

  17. 17

    Wrong file path while reading from UI

  18. 18

    Infinity loop while reading data from file

  19. 19

    bash: Prompting for user input while reading file

  20. 20

    .csv file reading from a specified URL

  21. 21

    Reading a csv file into csh using awk

  22. 22

    How do i choose where i output in a csv file

  23. 23

    In Python, how can I update multiple rows in a DataFrame with a Series?

  24. 24

    How can I view file header information?

  25. 25

    How can I save the last command to a file?

  26. 26

    How can I wait for the write of a file?

  27. 27

    How can I copy a text file into another?

  28. 28

    How can i replace particular characters in a file

  29. 29

    How can I test for a file having a value?

뜨겁다태그

보관