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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:02:05+00:00 2026-06-10T07:02:05+00:00

I have data in a numpy array (read from a .csv file). The relevant

  • 0

I have data in a numpy array (read from a .csv file). The relevant extract from np.genfromtxt is:

dtype = [("Category", "|S10"),
         ("Status", "|S11"),
         ("Date_start", object),
         ("Date_stop", object)],
names=True,
converters={2:lambda d:datetime.strptime(d, "%d/%m/%y"),
            3:lambda d:datetime.strptime(d, "%d/%m/%y")}
)

Everything works with one exception — accessing elements of the datetime objects. The following two lines of code return exactly what I expect:

print inp['Date_start'][1].month #returns 7
print np.where(inp['Category'] == '"R5"') #returns an array of matching indices

but the following line of code throws an AttributeError: 'numpy.ndarray' object has no attribute 'month'

print np.where(inp['Date_start'].month == 7)

This means I can’t return results based on which month things occurred in, which I need to.

Is there any way to get the behaviour I want from np.where?

  • 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-06-10T07:02:06+00:00Added an answer on June 10, 2026 at 7:02 am

    You could define a vectorized attribute getter:

    def func(a):
        return a.month
    
    vfunc = np.vectorize(func)
    

    and then use:

    np.where(vfunc(inp['Date_start']) == 7)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 2D array of Numpy data read from a .csv file. Each
I have data from travel diaries which has been read in from a csv
I have a numpy array which came from a cv2.imread and so has dtype
I have numpy array: >>> data dtype([('date', '|O4'), ('value', '<f8')] where date object is
I have an array of points in unknown dimensional space, such as: data=numpy.array( [[
I have data coming from an external system (in CSV form). The data contains
I have a large CSV data file -- ~1,444,000 rows of data -- that
I have the following range of numpy data (deltas of usec timestamps): array([ 4.312,
I have some python code which generates a 256^3 numpy array of data that
I have a numpy array which contains no data values. I mask those no

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.