-1

I have a data frame with date and time column

    data    published_at
0   0.0     2015-11-05T12:55:34.685Z
1   0.0     2015-11-05T12:55:44.695Z
2   0.0     2015-11-05T12:56:25.328Z
3   0.0     2015-11-05T12:56:35.333Z
4   0.0     2015-11-05T12:56:45.332Z

I wanted to convert into the following format

    data    published_at
0   0.0     2015-11-05 12:55:34.685
1   0.0     2015-11-05 12:55:44.695
2   0.0     2015-11-05 12:56:25.328
3   0.0     2015-11-05 12:56:35.333
4   0.0     2015-11-05 12:56:45.332
zx8754
  • 52,746
  • 12
  • 114
  • 209
sinshi k s
  • 43
  • 1
  • 8
  • We just want to remove T and Z ? – zx8754 Oct 18 '17 at 06:55
  • Possible duplicate of https://stackoverflow.com/questions/11936339/in-r-replace-text-within-a-string – zx8754 Oct 18 '17 at 06:55
  • 1
    Possible duplicate of [In R, replace text within a string](https://stackoverflow.com/questions/11936339/in-r-replace-text-within-a-string) – KoenV Oct 18 '17 at 07:17

1 Answers1

0

This will remove T and Z if your data frame is called df:

gsub("T"," ", df$published_at)
gsub("Z","", df$published_at)

Note that these are just strings and not dates/timestamps

f.lechleitner
  • 3,554
  • 1
  • 17
  • 35