numpy.genfromtxt produces array of what looks like tuples, not a 2D array—why?

What is returned is called a structured ndarray, see e.g. here: http://docs.scipy.org/doc/numpy/user/basics.rec.html. This is because your data is not homogeneous, i.e. not all elements have the same type: the data contains both strings (the first two columns) and floats. Numpy arrays have to be homogeneous (see here for an explanation). The structured array ‘solves’ this … Read more

Using numpy.genfromtxt to read a csv file with strings containing commas

You can use pandas (the becoming default library for working with dataframes (heterogeneous data) in scientific python) for this. It’s read_csv can handle this. From the docs: quotechar : string The character to used to denote the start and end of a quoted item. Quoted items can include the delimiter and it will be ignored. … Read more

tech