In the image shown, how can i split 'Date' column into 'Date' and 'Time' column?
Asked
Active
Viewed 1,733 times
1
-
2Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Feb 03 '17 at 06:37
1 Answers
3
You can use str.split
by whitespace
what is default separator:
df = pd.DataFrame({'Date':['4/1/2016 0.00','4/2/2016 0.05']})
print (df)
Date
0 4/1/2016 0.00
1 4/2/2016 0.05
df[['Date','Time']] = df.Date.str.split(expand=True)
print (df)
Date Time
0 4/1/2016 0.00
1 4/2/2016 0.05

jezrael
- 822,522
- 95
- 1,334
- 1,252