Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a field to a structured numpy array (3)

This has been asked and answered several times (here and here, for instance). Apparently the function has been moved in numpy 1.6.1. There is no more numpy.lib.recfunctions. While I can implement my own as specified in previous posts, I would really rather not!

Can someone tell me the path to this function? Have recfunctions as a whole been moved or merged into another library?

like image 723
Roland Avatar asked May 31 '26 16:05

Roland


2 Answers

According to the git history, numpy.lib.recfunctions hasn't gone anywhere.

I'd check your installation of numpy, and perhaps upgrade it to a newer version.

like image 81
perimosocordiae Avatar answered Jun 03 '26 04:06

perimosocordiae


This works for me... but I'm not clear why. Maybe someone can explain:

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']
>>>
like image 21
Curtis Price Avatar answered Jun 03 '26 05:06

Curtis Price