Python Forum
date format without time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
date format without time
#7
(Jan-15-2018, 03:59 PM)snippsat Wrote:
 >>> from datetime import datetime >>> d = ['11-01-2018'] >>> datetime.strptime(d, '%d-%m-%Y') Traceback (most recent call last): File "<string>", line 301, in runcode File "<interactive input>", line 1, in <module> TypeError: strptime() argument 1 must be str, not list # Fix >>> datetime.strptime(d[0], '%d-%m-%Y') datetime.datetime(2018, 1, 11, 0, 0)
You see that this generate the same error except it's a list, i fix it be taking the string out list using index. For Pandas Series object there is a pandas.Series.to_string


thanks for info, i changed the input format before loading to it. :)
Reply


Messages In This Thread
date format without time - by issac_n - Jan-15-2018, 10:53 AM
RE: date format without time - by buran - Jan-15-2018, 10:56 AM
RE: date format without time - by issac_n - Jan-15-2018, 01:59 PM
RE: date format without time - by metulburr - Jan-15-2018, 02:19 PM
RE: date format without time - by issac_n - Jan-15-2018, 03:50 PM
RE: date format without time - by snippsat - Jan-15-2018, 03:59 PM
RE: date format without time - by issac_n - Jan-19-2018, 10:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  replace nan values by mean group by date.year, date.month wissam1974 5 2,775 Feb-19-2020, 06:25 PM
Last Post: AnkitGupta
  Time Data does not match format AshBax 2 18,396 Nov-13-2018, 12:19 PM
Last Post: AshBax
  Finding date count from a list of date range in pandas trillerducas72 0 1,123 May-24-2018, 02:30 AM
Last Post: trillerducas72
  pandas convert date/time to week okl 3 3,755 Mar-03-2018, 10:15 PM
Last Post: marsokod
  is a pandas dataframe timeseries time index in a specified range (but ignoring date)? m_lotinga 4 15,097 Dec-12-2016, 10:51 PM
Last Post: m_lotinga

Forum Jump:

User Panel Messages

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