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

  • SEARCH
  • Home
  • 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 7577243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:08:05+00:00 2026-05-30T17:08:05+00:00

If I have a jagged list in python like jagged = [[1],[2,3]] how can

  • 0

If I have a jagged list in python like

jagged = [[1],[2,3]]

how can I declare it as an array using numpy and cython?
Is it possible somehow?
I know the following syntax, but it won’t do, as it gives only a 1D array.

cdef numpy.ndarray[np.float_t] jagged
  • 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-30T17:08:07+00:00Added an answer on May 30, 2026 at 5:08 pm

    Numpy arrays (both in and out of Cython) are typically rectangular. You don’t say what you’re trying to do with the jagged array, but you might be able to use:

    http://docs.scipy.org/doc/numpy/reference/maskedarray.html

    or:

    http://docs.scipy.org/doc/scipy/reference/sparse.html

    As for the 1-dimensional part of your question, you’re wanting the ndim param (mode=’c’ can speed things up if you won’t be getting any order=’F’ arrays):

    cdef numpy.ndarray[DTYPE_t, ndim=2, mode='c'] somearray
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jagged array that looks like this: string[][] list = new string[d.Rows.Count
I have a 2-dimensional jagged array (though it's always rectangular), which I initialize using
I have a jagged uint8 array like this in c++: UINT8 ras[2][3] = {{1,2,3},{4,5,6}}
I have what is essentially a jagged array of name value pairs - i
How could I accomplish copying one jagged array to another? For instance, I have
I have a simple setup like so.. ul { list-style: none; } #navigation ul
Say I have a jagged array, and position 2,3 is taken by int 3.
I have seen that declaring a bidimensional array as a jagged array is fine
I'm using jagged arrays and have a bit of a problem (or at least
I have a method which accept jagged array of Objects. public void MyDataBind(object[][] data)

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.