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 6104961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:54:09+00:00 2026-05-23T13:54:09+00:00

I have a 48×365 element numpy array where each element is a list containing

  • 0

I have a 48×365 element numpy array where each element is a list containing 3 integers. I want to be able to turn it into a 1×17520 array with all the lists intact as elements. Using

np.reshape(-1)

seems to break the elements into three separate integers and makes a 1×52560 array. So I either need a new way of rearranging the original array or a way of grouping the elements in the new np.reshape array (which are still in order) back into lists of 3.

Thanks for your help.

  • 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-23T13:54:09+00:00Added an answer on May 23, 2026 at 1:54 pm

    Is there a reason you can’t do it explicitly? As in:

    >>> a = numpy.arange(17520 * 3).reshape(48, 365, 3)
    >>> a.reshape((17520,3))
    array([[    0,     1,     2],
           [    3,     4,     5],
           [    6,     7,     8],
           ..., 
           [52551, 52552, 52553],
           [52554, 52555, 52556],
           [52557, 52558, 52559]])
    

    You could also do it with -1, it just has to be paired with another arg of the appropriate size.

    >>> a.reshape((17520,-1))
    array([[    0,     1,     2],
           [    3,     4,     5],
           [    6,     7,     8],
           ..., 
           [52551, 52552, 52553],
           [52554, 52555, 52556],
           [52557, 52558, 52559]])
    

    or

    >>> a.reshape((-1,3))
    array([[    0,     1,     2],
           [    3,     4,     5],
           [    6,     7,     8],
           ..., 
           [52551, 52552, 52553],
           [52554, 52555, 52556],
           [52557, 52558, 52559]])
    

    It occurred to me a bit later that you could also create a record array — this might be appropriate in some situations:

    a = numpy.recarray((17520,), dtype=[('x', int), ('y', int), ('z', int)])
    

    This can be reshaped in the original way you tried, i.e. reshape(-1). Still, as larsmans’ comment says, just treating your data as a 3d array is easiest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following numpy array: # A B C Y my_arr = np.array([
I have this string: 525,294,475,215,365,745 and i need to remove 475..and comma. and if
I have a javascript code, containing an array with trailing comma items:[{ id: 'col-1',
in C#,I have a double variable price with value 10215.24. I want to show
I have an array in php like this : Array ( [0] => Array
I have a UITableView that is being populated from an NSMutable array that has
I have found this example on StackOverflow: var people = new List<Person> { new
I want to have generalised email templates. Currently I have multiple email templates with
I have written a small example C++ program, using boost::thread. Since it's 215 lines,
I'm running Google Chrome 8.0.552.215 on Windows 7 x64 Ultimate. I have a simple

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.