2014-01-28 53 views
2

已多次詢問和回答此問題(例如,herehere)。顯然這個功能已經在numpy 1.6.1中移動了。沒有更多numpy.lib.recfunctions。雖然我可以實現我自己的以前的帖子中指定,我會真的而不是!將字段添加到結構化numpy數組(3)

有人能告訴我這個函數的路徑嗎?作爲一個整體已被移動或合併到另一個圖書館?

回答

3

根據git historynumpy.lib.recfunctions還沒有去過任何地方。

我會檢查你的numpy安裝,也許將其升級到更新的版本。

+0

好的。感謝那。我已經找到了庫和函數,所以我想我有一些時髦的w /我的配置。將回報。 – Roland

+0

在新系統上使用linux/conda遇到了這個問題。必須在頂部添加一個「import numpy.lib.recfunctions」調用。 – pyCthon

1

這適用於我...但我不清楚爲什麼。也許有人可以解釋:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import numpy 
>>> numpy.__version__ 
'1.6.1' 
>>> numpy.lib 
<module 'numpy.lib' from 'C:\Python27\ArcGIS10.1\lib\site-packages\numpy\lib\__init__.pyc'> 
>>> numpy.lib.recfunctions #### <- why does this not work? 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'recfunctions' 
>>> import numpy.lib.recfunctions 
>>> dir(numpy.lib.recfunctions) 
['MaskedArray', 'MaskedRecords', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_check_fill_value', '_fix_defaults', '_fix_output','_is_string_like', '_izip_fields', '_izip_fields_flat', 'append_fields', 'drop_fields', 'find_duplicates', 'flatten_descr', 'get_fieldstructure', 'get_names', 'get_names_flat', 'itertools', 'izip_records', 'join_by', 'ma', 'merge_arrays', 'ndarray', 'np', 'rec_append_fields', 'rec_drop_fields', 'rec_join', 'recarray', 'recursive_fill_fields', 'rename_fields', 'stack_arrays', 'sys', 'zip_descr'] 
>>> 
+0

這很有趣。顯式使用'import numpy.lib.recfunctions'也適用於我。至少這是一種解決方法。仍然想知道爲什麼我不能用正常的「進口numpy」進入'recfunctions'; numpy.lib.recfunctions'方法。 – Roland

+1

記錄了一個問題w/numpy人:https://github.com/numpy/numpy/issues/4242 – Roland

0

我發現,追加數組到一個記錄陣列,使用MLAB recfunctions是確定的,但numpy的recfunctions也不行。

import matplotlib.mlab as mlab 
mlab.rec_append_fields(recarray, names, data)