将1列分为2列pandas dataframe AttributeError .str

时间:2018-11-20 21:11:17

标签: python pandas dataframe

类型当然是 pandas.core.frame.DataFrame

数据就是这样

res["created_at"]
0 2018-11-15 02:14:38
1 2018-11-15 02:14:20
2 2018-11-15 02:13:34
3 2018-11-15 01:53:18
...

我需要将“ create_at”分为“日期”和“时间”,但是当我根据这个问题How to split a column into two columns?尝试这样做时:

res['date'], res['time'] = res['created_at'].str.split(' ', 1).str**

res['created_at'].str.split(' ', 1, expand=True)

在两种情况下,我都会收到以下错误消息:

AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas

0 个答案:

没有答案