Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:51:23+00:00 2026-05-12T17:51:23+00:00

Is there an easy way to add a record/row to a numpy recarray without

  • 0

Is there an easy way to add a record/row to a numpy recarray without creating a new recarray? Let’s say I have a recarray that takes 1Gb in memory, I want to be able to add a row to it without having python take up 2Gb of memory temporarily.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:51:24+00:00Added an answer on May 12, 2026 at 5:51 pm

    You can call yourrecarray.resize with a shape which has one more row, then assign to that new row. Of course. numpy might still have to allocate completely new memory if it just doesn’t have room to grow the array in-place, but at least you stand a chance!-)

    Since an example was requested, here comes, modified off the canonical example list…:

    >>> import numpy
    >>> mydescriptor = {'names': ('gender','age','weight'), 'formats': ('S1', 'f4', 'f4')} 
    >>> a = numpy.array([('M',64.0,75.0),('F',25.0,60.0)], dtype=mydescriptor)
    >>> print a
    [('M', 64.0, 75.0) ('F', 25.0, 60.0)]
    >>> a.shape
    (2,)
    >>> a.resize(3)
    >>> a.shape
    (3,)
    >>> print a
    [('M', 64.0, 75.0) ('F', 25.0, 60.0) ('', 0.0, 0.0)]
    >>> a[2] = ('X', 17.0, 61.5)
    >>> print a
    [('M', 64.0, 75.0) ('F', 25.0, 60.0) ('X', 17.0, 61.5)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any easy way to add a using statement to every class I
Is there an easy way to add nodes to a WinForms .NET TreeView control
Is there an easy way to add a permanent string to every route in
Just wondering if there is an easy way to add the functionality to duplicate
Is there an easy way to iterate over an associative array of this structure
Is there an easy way in C# to create Ordinals for a number? For
Is there an easy way to produce MSDN-style documentation from the Visual Studio XML
Is there an easy way to avoid dealing with text encoding problems?
Is there an easy way to tell if a ruby script is already running
Is there an easy way to set the zoom level for a windows form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.