Python中文
首页
教程
问答
标签
搜索
登录
注册
根据anoth的索引从数据帧中查询行的子集
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我有一个5分钟欧元美元的数据框,还有一个非农场工资数据的数据框。我想创建一个新的dataframe,其中包含NFP日期的所有eursud 5分钟数据行。见下文:</p> <pre><code>#NFP Days (Dataframe #1) nfp_dates = forex_calendar.loc[forex_calendar['Event'] == '(United States) Nonfarm Payrolls'] </code></pre> <p><a href="https://i.stack.imgur.com/6RgQF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6RgQF.png" alt="enter image description here"/></a> #将csv文件导入Pandas dataframes并转换为Pandas datetime并设置为index(Dataframe#2)</p> ^{2}$ <p><a href="https://i.stack.imgur.com/z6s6G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z6s6G.png" alt="enter image description here"/></a></p> <p>所需数据帧(数据帧3) 我想要一个名为“eurusd_ask_nfp”的新数据帧,其中包含nfp日期(即2012-01-06、2012-02-03、2012-03-09等)的所有5分钟数据行(全天)</p> <pre><code>Open High Low Close Volume Gmt time 2012-01-06 00:00:00 1.23627 1.23627 1.23532 1.23553 860.47 2012-01-06 00:05:00 1.23553 1.23553 1.23509 1.23532 698.33 2012-01-06 00:10:00 1.23533 1.23535 1.23518 1.23533 338.22 2012-01-06 00:15:00 1.23533 1.23535 1.23511 1.23518 480.64 2012-01-06 00:20:00 1.23518 1.23525 1.23493 1.23508 551.73 2012-01-06 00:25:00 1.23509 1.23537 1.23501 1.23512 349.78 2012-01-06 00:30:00 1.23510 1.23520 1.23471 1.23481 659.66 ... ... ... ... ... ... 2012-02-03 00:00:00 1.33271 1.33271 1.33210 1.33225 870.59 2012-02-03 00:05:00 1.33225 1.33248 1.33212 1.33227 943.04 2012-02-03 00:10:00 1.33226 1.33226 1.33189 1.33212 659.45 2012-02-03 00:15:00 1.33213 1.33272 1.33212 1.33268 788.32 2012-02-03 00:20:00 1.33265 1.33333 1.33264 1.33315 953.20 2012-02-03 00:25:00 1.33315 1.33322 1.33282 1.33286 678.37 2012-02-03 00:30:00 1.33286 1.33291 1.33260 1.33260 442.39 2012-02-03 00:35:00 1.33261 1.33293 1.33250 1.33268 621.53 2012-02-03 00:40:00 1.33268 1.33292 1.33257 1.33288 511.00 2012-02-03 00:45:00 1.33288 1.33300 1.33240 1.33240 554.76 2012-02-03 00:50:00 1.33240 1.33240 1.33191 1.33225 839.80 ... ... ... ... ... ... 2012-03-09 00:00:00 1.25739 1.25748 1.25710 1.25711 439.46 2012-03-09 00:05:00 1.25712 1.25732 1.25709 1.25715 388.29 2012-03-09 00:10:00 1.25715 1.25733 1.25711 1.25726 291.65 2012-03-09 00:15:00 1.25729 1.25731 1.25685 1.25692 626.85 2012-03-09 00:20:00 1.25692 1.25696 1.25662 1.25663 394.68 2012-03-09 00:25:00 1.25662 1.25677 1.25648 1.25652 302.73 2012-03-09 00:30:00 1.25652 1.25665 1.25645 1.25646 457.76 2012-03-09 00:35:00 1.25646 1.25659 1.25629 1.25633 423.00 2012-03-09 00:40:00 1.25633 1.25649 1.25632 1.25641 173.08 2012-03-09 00:45:00 1.25642 1.25671 1.25630 1.25665 263.99 ... ... ... ... ... ... etc., etc. </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>尝试一下,但是您应该能够使用<code>Index.isin</code>来查询日期匹配的所有记录。在</p> <pre><code>idx = nfp_dates.index eurusd_ask_nfp = eurusd_ask[eurusd_ask.index.isin(idx)] </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python中两个字典的交集
10 回答
python中两个字符串上的异或操作数?
6 回答
Python中两个字符串中的类似句子
9 回答
Python中两个字符串之间的Hamming距离
9 回答
python中两个字符串之间的匹配模式
3 回答
python中两个字符串之间的按位或
6 回答
python中两个字符串之间的数据(字节)切片
8 回答
python中两个字符串之间的模式
3 回答
python中两个字符串作为子字符串的区别
10 回答
Python中两个字符串元组的比较
8 回答
Python中两个字符串列表中的公共字符串
10 回答
python中两个字符串的Anagram测试
2 回答
Python中两个字符串的正则匹配
3 回答
python中两个字符串的笛卡尔乘积
5 回答
Python中两个字符串相似性的比较
4 回答
python中两个字符串语义相似度的求法
5 回答
Python中两个字符置换成固定长度的字符串,每个字符的数目相等
6 回答
Python中两个对数方程之间的插值和平滑数据
6 回答
Python中两个对象之间的And/Or运算符
5 回答
python中两个嵌套字典中相似键的和值
10 回答