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?

0

3 Answers 3

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.

2
  • 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. Commented Jan 28, 2014 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. Commented Dec 28, 2016 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']
>>>
2
  • 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. Commented Jan 28, 2014 at 21:34
  • I still have the same issue with numpy 1.19.2. Super weird. Commented Oct 13, 2021 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)
1
  • is there any reason for your assessment? Commented Nov 12, 2020 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.