我有一个数据框,其中年、月、日、小时被分成单独的列:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Your Site Title</title>
</head>
<body>
<%= require('html-loader!./views/partial/nav.html') %>
<main id="mainDiv">
<!-- Section Banner -->
<%= require('html-loader!./views/partial/index/section-banner.html') %>
<!-- Section Services -->
<%= require('html-loader!./views/partial/index/section-services.html') %>
<!-- Section About us -->
<%= require('html-loader!./views/partial/index/section-aboutus.html') %>
<!-- Section Call To Action -->
<%= require('html-loader!./views/partial/index/section-call-to-action.html') %>
<!-- Section Footer -->
<%= require('html-loader!./views/partial/footer.html') %>
</main>
</body>
</html>
我想向数据框添加一个适当的日期时间列,所以我最终得到了以下内容:
df.head()
Year Month Day Hour
0 2020 1 1 0
1 2020 1 1 1
2 2020 1 1 2
...
我可以添加一个一次处理一行的循环,但这不是熊猫式的。 以下是三件行不通的事情(并不是我希望他们中的任何一个这样做):
df.head()
Year Month Day Hour datetime
0 2020 1 1 0 2020-01-01T00:00
1 2020 1 1 1 2020-01-01T01:00
2 2020 1 1 2 2020-01-01T02:00
...