I try to add data to a np array with mixed data, integers and strings. From numpy.org i got:
To use actual strings in Python 3 use U or numpy.str_.
However, if i use U or numpy:str_ if get
invalid literal for int() with base 10: 'fileA'
So I am pretty sure I misinterpreted somethine about the string or dtype. How do i get columns for strings in a mixed array in numpy? Thanks!
import sys
import numpy as np
document_dtype = np.dtype({'names': ['global_line','filename', 'file_line','type','text'], 'formats': ['i','U','i','U','U']})
document = np.empty(shape=(0,5), dtype=document_dtype)
document = np.vstack([document, np.array([2,'fileA',1,'Header','Test'],dtype=document_dtype)])