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?

Community
  • 1
  • 1
Roland
  • 499
  • 6
  • 16

3 Answers3

3

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.

perimosocordiae
  • 17,287
  • 14
  • 60
  • 76
  • okay. Thanks for that. I've found the library and the function, so I'm thinking I have something funky w/my configuration. Will report back. – Roland Jan 28 '14 at 19:09
  • ran into this issue using linux/conda on a new system. Had to add a `import numpy.lib.recfunctions` call at the top. – pyCthon Dec 28 '16 at 13:51
3

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']
>>>
Curtis Price
  • 401
  • 4
  • 6
  • That's interesting. Explicitly using `import numpy.lib.recfunctions` works for me as well. At least this is a workaround. Still would like to know why I can't get to `recfunctions` with the normal `import numpy; numpy.lib.recfunctions` approach. – Roland Jan 28 '14 at 21:34
  • I still have the same issue with numpy 1.19.2. Super weird. – mapf Oct 13 '21 at 14:36
0

I found that to append array to a record array, use mlab recfunctions is OK but numpy recfunctions is NOT OK.

import matplotlib.mlab as mlab
mlab.rec_append_fields(recarray, names, data)
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
football
  • 19
  • 4