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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:51:10+00:00 2026-06-13T18:51:10+00:00

In Numpy, I am trying to get the time of day for each element

  • 0

In Numpy, I am trying to get the time of day for each element in an array of datatime64.

I could settle for a new array of timedelta64 which contains the time passed since the beginning of day for each element.

I already tried using numpy.datetime_as_string, but I don’t know how to manipulate the string.

  • 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-13T18:51:11+00:00Added an answer on June 13, 2026 at 6:51 pm
    def datetime64_to_time_of_day(datetime64_array):
        """
        Return a new array. For every element in datetime64_array return the time of day (since midnight).
        >>> datetime64_to_time_of_day(np.array(['2012-01-02T01:01:01.001Z'],dtype='datetime64[ms]'))
        array([3661001], dtype='timedelta64[ms]')
        >>> datetime64_to_time_of_day(np.datetime64('2012-01-02T01:01:01.001Z','[ms]'))
        numpy.timedelta64(3661001,'ms')
        """
        day = datetime64_array.astype('datetime64[D]').astype(datetime64_array.dtype)
        time_of_day = datetime64_array - day
        return time_of_day
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transform each element of a numpy array into an array itself
I am trying to get a bincount of a numpy array which is of
I'm trying to get a table form a numpy array at the barplot bottom
I have a numpy array of ints representing time periods, which I'm currently plotting
I'm trying to do an array operation with numpy.nditer , but don't get the
Trying to convert int arrays to string arrays in numpy In [66]: a=array([0,33,4444522]) In
The numpy.equal function does not work if a list or array contains strings: >>>
I have an numpy array which I save to a image using savefig(). Then
I'm trying to get a better grip on numpy arrays, so I have a
I'm trying to using numpy.lib.stride_tricks.as_strided to iterate over non-overlapping blocks of an array, but

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.