我有一个numpy记录数组,其中填充了具有Unicode字符的列 当我尝试运行np.save时,它失败并正在使用编码“ latin-1”
Failure to write pandas [] to memory: 'latin-1' codec can't encode character '\u272a' in position 3070: ordinal not in range(256)
Traceback (most recent call last):
File "D:\WindowsDocuments\GitHub\ReplayAnalysis\carball\analysis\utils\numpy_manager.py", line 30, in convert_numpy_array
np.save(compressed_array, numpy_array, allow_pickle=True, fix_imports=False)
File "C:\Users\David Windows\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\npyio.py", line 521, in save
pickle_kwargs=pickle_kwargs)
File "C:\Users\David Windows\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\format.py", line 572, in write_array
version)
File "C:\Users\David Windows\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\format.py", line 315, in _write_array_header
header = asbytes(_filter_header(header))
File "C:\Users\David Windows\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\compat\py3k.py", line 35, in asbytes
return str(s).encode('latin1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u272a' in position 3070: ordinal not in range(256)
似乎在酸洗时是一个问题。 有没有办法用UTF-8强制np.save腌制?
我不想使用保存txt,因为大小很重要,因此首选二进制格式。