Questions tagged [strptime]

`strptime` reads the time from the string s using the timeformat specifiers and converts it into seconds since the year 2000.

779 questions
2
votes
4 answers

Using strptime() on a list of strings. Cannot use loops

I have a list of strings (unicode). Like so: >>> tstamp [u'2017-08-08T08:51:20.465Z', u'2017-08-08T08:51:27.871Z', u'2017-08-08T08:51:33.399Z', u'2017-08-08T08:51:37.530Z', u'2017-08-08T08:51:47.248Z', u'2017-08-08T08:51:50.414Z',…
Tanmay
  • 265
  • 4
  • 13
2
votes
1 answer

KeyError: 0 when changing time format of data

I have a column of data that are date formatted as "%d%m%Y" like "15022016". I need to convert them as "%Y-%m-%d" like"2016-02-15". The data frame have 911,462 rows, and the code is as below: for i in range(0,911462): …
Vane Leung
  • 65
  • 4
2
votes
1 answer

strptime handling space in fixed format string

Is there a way to get strptime() to handle fixed format time strings? I need to parse a time string that is always on the fixed width format: "yymmdd HHMMSS", but with the complication that leading zeros are sometimes present and sometimes not.…
cpaitor
  • 423
  • 1
  • 3
  • 16
2
votes
3 answers

saving datetime with milliseconds and time zone - python

I can't figure out the correct second argument of strptime for the following date format a = datetime.strptime('2017-03-09 14:00:00.000000+0000', '%y-%m-%d %H:%M:%S.%f+%z') The error I get is: ValueError: time data '2017-03-09 14:00:00.000000+0000'…
Lukasz
  • 2,257
  • 3
  • 26
  • 44
2
votes
0 answers

Parsing a time-string, Python

I struggle parsing a date/time-string with datetime.strptime: date = "30. Dez 2016 19:34" format = "%d. %b %Y %H:%M" dt = datetime.strptime(date, format) dt Raises a value error: ValueError: time data '30. Dez 2016 19:34' does not match format '%d.…
Jean Zombie
  • 607
  • 1
  • 9
  • 28
2
votes
0 answers

R: Inconsistency in as.POSIXct and strptime

I've been dealing with adjusting parsed time stamps for Daylight Savings Time and observed some odd behavior... namely, as.POSIXct and strptime do not produce consistent behavior during the roll-back hour. More specifically "11/2/2014 1:45:15 AM"…
Constantine
  • 479
  • 1
  • 9
  • 19
2
votes
1 answer

Why strptime c-function changes the structure?

Incomprehensible behavior of the function strptime(): #define _XOPEN_SOURCE #include #include double getPeriod(char * dateStart, char * dateStop) { struct tm tmStart, tmStop; time_t timeStampStart, timeStampStop; …
Sergey
  • 23
  • 2
2
votes
1 answer

ValueError: Setting void-array with object members using buffer. Plotting a timeseries of an numpy array

I have 2 numpy arrays with (time and date), and the third with rain. At the end I would like to plot all the info at a xy-plot with matplotlib! This i what I got so far import os import time from datetime import datetime import time import numpy as…
Markus
  • 189
  • 1
  • 1
  • 10
2
votes
1 answer

Issues with creating a new column in datatable using strptime

I've got some data which is character class: class(solarX[,MEASDATE]) [1] "character" Which looks like : head(solarX[,MEASDATE]) [1] "1/05/2015 0:00" "1/05/2015 0:30" "1/05/2015 1:00" "1/05/2015 1:30" "1/05/2015 2:00" "1/05/2015…
Gin_Salmon
  • 837
  • 1
  • 7
  • 19
2
votes
1 answer

strptime doesn't work exactly

My data.frame is like this: ï..Date Open High Low Close 1 29-Apr-16 85525.08 85664.35 84837.94 85327.80 2 28-Apr-16 85467.41 85676.38 84763.17 85477.83 3 27-Apr-16 85877.39 86121.04 85291.50 85374.19 4 26-Apr-16…
Enes I.
  • 125
  • 1
  • 8
2
votes
2 answers

Pandas : How to get timestamp.day and timestamp.month with padded zero

rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 I want the output with a padded zero. i.e : 07 02 a)Is there any ready function to change the format of the .day and .month? b)Is there any other way…
revoltman
  • 101
  • 3
  • 12
2
votes
1 answer

strptime giving "implicit declaration" and "undefined reference"

So, when I use the function strptime I get both a warning: warning: implicit declaration of function 'strptime' and an error after that: undefined reference to 'strptime' Yes, I've included time.h. Here is a small sample code of me using…
Rob Avery IV
  • 3,562
  • 10
  • 48
  • 72
2
votes
1 answer

Formatting Dates in R (Non-standard format)

Not new to R or formatting dates in R and wouldn't be asking this question but I am having seriously strange behavior and in the last 2 hours am no closer to resolving it. I have a dataset which I have imported and want to format the date/time…
CCurtis
  • 1,770
  • 3
  • 15
  • 25
2
votes
3 answers

Perl strptime parse millisecond

I need to parse some time string that comes in a format like ddmmyyyyhhmmssXXX. The XXX part is millisecond. In the below code Im ignoring the millisecond part. It works but I get the error: garbage at end of string in strptime: 293 at…
Kamrul Khan
  • 3,260
  • 4
  • 32
  • 59
2
votes
1 answer

"list indices must be integers, not str' error when using strptime function

I have a list of dates, written as strings, called depart_date depart_date = ['3/1/2012', '3/4/2012', '3/11/2012'] etc. I'd like to convert them to date objects. This is what I have: for i in depart_date: dep_date =…
python_amateur
  • 85
  • 1
  • 1
  • 7