2017-10-18 102 views
-1

我有日期和時間列的數據幀轉換 「2016-08-28T17:12:41.795Z」 到 「2016年8月28日17:12:41.795」

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 

我想轉換成以下格式

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 
+0

我們只是想移除T和Z? – zx8754

+0

可能的重複https://stackoverflow.com/questions/11936339/in-r-replace-text-within-a-string – zx8754

+1

可能重複[在R中,替換字符串內的文本](https:// stackoverflow。 COM /問題/ 11936339 /在-R替換文本中之弦) – KoenV

回答

0

這將除去T和Z如果您的數據幀被稱爲df

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

注意,這些只是字符串而不是日期/時間戳

相關問題