问题描述
如何填充日期列,以便在检测到日期时将该日期添加到下面的行中,直到它看到一个新日期开始添加该日期?
可重现的例子:
输入:
Date Headline
0 Mar-20-21 04:03AM Apple CEO Cook,executives on tentative list o...
1 03:43AM Apple CEO Cook,execs on tentative list of wit...
2 Mar-19-21 10:19PM Dow Jones Futures: Why This Market Rally Is So...
3 06:13PM Zuckerberg: Apples Privacy Move Could Spur Mor...
4 05:45PM Apple (AAPL) Dips More Than Broader Markets: W...
5 04:17PM Facebook Stock Jumps As Zuckerberg Changes Tun...
6 04:03PM Best Dow Jones Stocks To Buy And Watch In Marc...
7 01:02PM The Nasdaq's on the Rise Friday,and These 2 S...
期望的输出:
Date Headline
0 Mar-20-21 04:03AM Apple CEO Cook,executives on tentative list o...
1 Mar-20-21 03:43AM Apple CEO Cook,execs on tentative list of wit...
2 Mar-19-21 10:19PM Dow Jones Futures: Why This Market Rally Is So...
3 Mar-19-21 06:13PM Zuckerberg: Apples Privacy Move Could Spur Mor...
4 Mar-19-21 05:45PM Apple (AAPL) Dips More Than Broader Markets: W...
5 Mar-19-21 04:17PM Facebook Stock Jumps As Zuckerberg Changes Tun...
6 Mar-19-21 04:03PM Best Dow Jones Stocks To Buy And Watch In Marc...
7 Mar-19-21 01:02PM The Nasdaq's on the Rise Friday,and These 2 S...
尝试:
df['Time'] = [x[-7:] for x in df['Date']]
df['Date'] = [x[:-7] for x in df['Date']]
# Some code that fills the date
# Then convert to datetime
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)