Using genfromtxt to import csv data with missing values in numpy

前端 未结 2 1139
野性不改
野性不改 2020-12-01 17:37

I have a csv file that looks something like this (actual file has many more columns and rows):

1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16

Say t

相关标签:
2条回答
  • 2020-12-01 18:08

    if you can ignore the 16 at the end of the file try using the

    invalid_raise (bool, optional) parameter if set to False it ignores all incomplete lines without throwing an exception

    see here (its the last parameter before the examples) http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html

    0 讨论(0)
  • 2020-12-01 18:20

    The command filling_values also helped me. I set it to zero. Thus each empty value is set to zero. It probably doesn't always make sense, but maybe it will help you.

    0 讨论(0)
提交回复
热议问题