将一系列DateTime值转换为正确的格式

时间:2018-08-27 18:32:53

标签: python pandas datetime matplotlib

当前,我有一系列的Datetime值显示为

0  Datetime
1  20041001
2  20041002
3  20041003
4  20041004

它们在一个名为

的系列中
d['Datetime']

它们最初是类似     20041001ABCDEF 但是我只剩下最后的数字了。如何将它们设置为以下格式?

2004-10-01

1 个答案:

答案 0 :(得分:1)

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title>John Modica | CybernetiX S3C</title>

	<link rel="icon" href="favicon.ico" type="image/png" />

	<link href="https://fonts.googleapis.com/css?family=Reem+Kufi|Roboto:300" rel="stylesheet">
	<link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/styles.css">
	<!-- <link rel="stylesheet" href="css/themes/indigo-white.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/green-white.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/red-white.css"> -->
	<link rel="stylesheet" href="css/themes/grey-white.css">
	<!-- <link rel="stylesheet" href="css/themes/white-indigo.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/white-blue.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/white-grey.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/white-red.css"> -->
	<!-- <link rel="stylesheet" href="css/themes/yellow-black.css"> -->
</head>
<body>
	<main>
		<p><img src="https://img.shields.io/badge/Welcome_To-CybernetiX--S3C-cyan.svg?longCache=true&style=for-the-badge" alt="Welcome" width="300px" align="middle"></p>
		
		<div class="intro">Greetings from:</div>
		<a href="https://ibb.co/du9CxJ"><img src="https://image.ibb.co/bMZecJ/lJeA3tgA.gif" alt="lJeA3tgA" border="0"></a>
		<div class="tagline">All-Star Dev | Code Fanatic | Linux Hacker | Cyber Security Professional</div>
		<!-- Find your icons from here - https://fontawesome.com/icons?d=gallery&s=brands -->
		<div class="icons-social">
			<a target="_blank" href="https://CybernetiX-S3C.github.io/main" align="middle" title="Main" rel="nofollow"><i class="fab fa-github"></i>Main</a>
			<!-- <a target="_blank" href="https://twitter.com/flexdinesh"><i class="fab fa-twitter"></i></a> -->
			<!-- <a target="_blank" href="https://Encrypted-Crack.g"><i class="fas fa-user"></i></a> -->
			<a target="_blank" href="https://www.linkedin.com/in/john-modica-228219b5" align="middle" title="LinkedIn" rel="nofollow"><i class="fab fa-linkedin"></i>LinkedIn</a>
			<a target="_blank" href="https://medium.com/@dmferreira/interview-with-cyber-threat-specialist-john-modica-d3708b235207" align="middle" title="Medium" rel="nofollow"><i class="fab fa-medium"></i>Medium</a>
			<a target="_blank" href="https://www.youtube.com/channel/UCAOxHOEpTxpwpmrwy5edWHg" align="middle" title="YouTube" rel="nofollow"><i class="fab fa-youtube"></i>Youtube</a>			
			<a target="_blank" href="https://www.facebook.com/Cyber.S3C.Professional" align="middle" title="Facebook" rel="nofollow"><i class="fab fa-facebook-f"></i>Faceboot</a>			
			<a target="_blank" href="https://DarkJpeg-Stego.github.io/" align="middle" title="DarkJpeg" rel="nofollow"><i class="fas fa-eye"></i>DarkJpeg</a>			
			<a target="_blank" href="https://Encrypted-Crack.github.io/" align="middle" title="Encrypted Crack" rel="nofollow"><i class="fas fa-user-secret"></i>Encrypted-Crack</a>
			<a target="_blank" href="https://join.slack.com/t/officialcybernetixs3c/shared_invite/enQtNDA5MzIzMzg0OTk0LWNkOTI0N2MzMWJiZDMyYjA4NWI3ODhhNmNhZDdhNTIzY2YzMDFkY2NiMGIxM2FlOWVjYTJmMzRkZDA3Y2Y1MzM" align="middle" title="Slack" rel="nofollow"><i class="fab fa-slack"></i>Slack</a>
			<script type="text/javascript">
			var _sz=_sz||{};_sz.appId="20dead96",function(){var e=document.createElement("script");e.src="https://cdn.signalzen.com/signalzen.js",e.setAttribute("async","true"),document.documentElement.firstChild.appendChild(e);var t=setInterval(function(){"undefined"!=typeof SignalZen&&(clearInterval(t),new SignalZen(_sz).load())},10)}();
			</script>
		</div>
	</main>
</body>
</html>