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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:54:53+00:00 2026-05-26T12:54:53+00:00

Ok, So I have a 2-d array of data which has the shape(23025, 1000),

  • 0

Ok, So I have a 2-d array of data which has the shape(23025, 1000), it’s called ‘allfiles’.

I need to go through the array 50 columns at a time and extract them to a sub-array for manipulation. The problem is when i address the array using the code below, it doesn’t seem to recognize the variables (a and b). the code i have at the moment is shown below.

    q = 50
    a = np.shape(allfiles)[1] # a = 1000
    for i in range(a):
        b = a + q
        data = allfiles[:,a:b]

When i replace the variables with number, i.e…

    data = allfiles[:,30:80]

It seems to work. So, my question is – is there a way i can pass variables to the array index? If not is there a better way i can create a subarray using variables?

I have tried to find this problem on stack overflow with no luck, but i’m sure i’m not the first person to have this trouble?

Cheers guys,
Morgan

  • 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-26T12:54:54+00:00Added an answer on May 26, 2026 at 12:54 pm

    You are getting i from the loop but don’t use it.

    q = 50
    
    for start in xrange(0, allfiles.shape[1], q):
        data = allfiles[:,start:start+q]
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structured array (1x1) called 'Data' which has 3 fields. Each field
I have a string say string s =C:\\Data , I have an array which
I have a generated nested Array which I store some data. How can i
I have a two-dimensional array (of Strings) which make up my data table (of
I have a big lump of binary data in a char[] array which I
I have some binary data which has a corresponding map file which identifies each
I have an Array in PHP which contains data from database. And it prints
I have a Winform DataGridView , which has a number of predefined columns. Now
Say I have a database which has the following layout: Fields: |Business_Name| |Business_ID| Data
I often* find myself in need of a data structure which has the following

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.