我有一个美国民意调查数据的数据框,我试图每天填写。我无法弄清楚如何去做。
这是原始数据(数据框不必是多索引)。
Democratic Other Republican
Date State
2008-11-04 AZ 0.451153 0.012495 0.536352
2012-05-20 AZ 0.462500 0.000000 0.537500
...
2008-11-04 WI 0.562178 0.014686 0.423137
2012-11-03 WI 0.515152 0.000000 0.484848
我想填写它看起来像这样:
Democratic Other Republican
Date State
2008-11-04 AZ 0.451153 0.012495 0.536352
2008-11-05 AZ 0.451153 0.012495 0.536352
...
2012-05-20 AZ 0.462500 0.000000 0.537500
2012-05-21 AZ 0.462500 0.000000 0.537500
...
2012-11-06 AZ 0.462500 0.000000 0.537500
...
2008-11-04 WI 0.562178 0.014686 0.423137
2008-11-05 WI 0.562178 0.014686 0.423137
...
2012-11-03 WI 0.515152 0.000000 0.484848
2012-11-04 WI 0.515152 0.000000 0.484848
2012-11-05 WI 0.515152 0.000000 0.484848
2012-11-06 WI 0.515152 0.000000 0.484848
我试过这样做:
election_range = pd.date_range('2008-11-06', '2012-11-06')
dailies.reindex(election_range, method='pad')
但是我收到了这个错误:
ValueError: cannot include dtype 'M' in a buffer
我尝试在日期上编制索引,但我收到的错误是索引不是唯一的。
显而易见的事情是逐帧拆分帧,重新索引并组合帧,但必须有更好的方法。有没有人有任何想法?
答案 0 :(得分:0)
尝试:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<head>
<title>JQuery Event Listener</title>
<script src = "jquery-3.0.0.js"></script>
<style>
</style>
</head>
<body>
<header>
<br>
<h1>Let's Have Fun!</h1>
<button id = "btn1" data-panel="1">Button1</button>
<button id = "btn2" data-panel="2">Button2</button>
<button id = "btn3" data-panel="3">Button3</button>
<button id = "btn4" data-panel="4">Button4</button>
<br><br>
</header>
<br><br>
<div class="main">
<div class="panel-container">
<div id="panel1" class="panel">
<div class = "panel-Heading">Panel1</div>
<div class = "panel-Body">Content</div>
</div>
</div>
<div class="panel-container">
<div id="panel2" class="panel">
<div class = "panel-Heading">Panel2</div>
<div class = "panel-Body">Content</div>
</div>
</div>
<div class="panel-container">
<div id="panel3" class="panel">
<div class = "panel-Heading">Panel3</div>
<div class = "panel-Body">Content</div>
</div>
</div>
<div class="panel-container">
<div id="panel4" class="panel">
<div class = "panel-Heading">Panel4</div>
<div class = "panel-Body">Content</div>
</div>
</div>
</div>
</body>