Python Forum
[Numpy] Load date/time from .txt to 'datetime64' type.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Numpy] Load date/time from .txt to 'datetime64' type.
#4
(Mar-01-2024, 09:30 AM)Gribouillis Wrote: def gen(file):
for line in file:
t = dt.datetime.strptime(line, "%Y-%m-%d, %H:%M:%S\n")
yield t.isoformat()

That seems a good method for this case, thanks.
Reply


Messages In This Thread
RE: [Numpy] Load date/time from .txt to 'datetime64' type. - by water - Mar-01-2024, 07:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 963 Mar-26-2024, 02:18 PM
Last Post: snippsat
  GroupBy - Sum = Error [datetime64 type does not support sum operations] BSDevo 4 3,601 Oct-27-2023, 07:22 PM
Last Post: BSDevo
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,857 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,832 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Does a pandas have a date without a time? AlekseyPython 6 5,127 Feb-10-2021, 09:24 AM
Last Post: Naheed
  How to fill datetime64 field in numpy structured array? AlekseyPython 0 2,382 Oct-20-2020, 08:17 AM
Last Post: AlekseyPython
  How to prepare a NumPy array which include float type array elements subhash 0 1,989 Mar-02-2020, 06:46 AM
Last Post: subhash
  replace nan values by mean group by date.year, date.month wissam1974 5 8,764 Feb-19-2020, 06:25 PM
Last Post: AnkitGupta
  Problem with date type (object to datetime) karlito 6 3,816 Oct-16-2019, 08:07 AM
Last Post: karlito
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 3,123 Apr-09-2019, 04:54 PM
Last Post: PhysChem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020