简体   繁体   English

天真的问题:从所有四个不同的链接接收相同的数据

[英]Naive Problem: Receiving same data from all four different links

import pandas as pd
df31_12_r1 = pd.read_html('https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html#r1')[0]

df31_12_r2 = pd.read_html('https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html#r2')[0]

df31_12_r3 = pd.read_html('https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html#r3')[0]

df31_12_r4 = pd.read_html('https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html#r4')[0]

The result displayed is the same from all the data frame, however it should be different: One result is displayed (other three are similar):所有数据框显示的结果都相同,但应该不同:显示一个结果(其他三个类似):


Unit    Power   Down    Reason or Comment   Change in report (*)    Number of Scrams (#)
0   Beaver Valley 1 100 NaN NaN NaN NaN
1   Beaver Valley 2 100 NaN NaN NaN NaN
2   Calvert Cliffs 1    100 NaN NaN NaN NaN
3   Calvert Cliffs 2    100 NaN NaN NaN NaN
4   FitzPatrick 100 NaN NaN NaN NaN
5   Ginna   100 NaN NaN NaN NaN
6   Hope Creek 1    0   10/10/2004  REFUELING OUTAGE    NaN NaN
7   Indian Point 2  100 NaN NaN NaN NaN
8   Indian Point 3  100 NaN NaN NaN NaN
9   Limerick 1  99  NaN REDUCED POWER DUE TO FEEDWATER FLOW CONCERNS    NaN NaN

How we can get exact data to each link instead, link pulling only top CSV file data from the webpage?我们如何才能获得每个链接的准确数据,链接仅从网页中提取顶部 CSV 文件数据? Thank you in advance for help!提前感谢您的帮助!

All tables are in one html page, so is possible create list of DataFrames dfs and then select by index:所有表都在一个 html 页面中,因此可以创建 DataFrames dfs列表,然后按索引创建 select:

url = 'https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html'
dfs = pd.read_html(url)


df1 = dfs[0]
df2 = dfs[1]
df3 = dfs[2]
df4 = dfs[3]

print (df1.head())
print (df2.head())
print (df3.head())
print (df4.head())

If need one DataFrame with join list of DataFrames dfs add concat :如果需要一个 DataFrame 与 DataFrames dfs的连接列表添加concat

url = 'https://www.nrc.gov/reading-rm/doc-collections/event-status/reactor-status/2004/20041231ps.html'
dfs = pd.read_html(url)

df = pd.concat(dfs, ignore_index=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以同时显示四种不同类型数据的可视化 - A visualization that can show four different type of data at the same time 从页面获取所有链接,收到 javascript.void() 错误? - Getting all links from page, receiving javascript.void() error? 从列表中删除相同但不同的链接 url - Remove from a list same links but with different url 使用Flask在同一页面之间发送和接收数据 - Sending and receiving data to and from the same page with Flask Paramiko 未从频道接收所有数据 - Paramiko not receiving all data from Channel 以四种不同方式汇总数据 - Aggregating data in four different ways 从同一网站的链接中获取数据 - Grabbing data from sperate links of the same website 从 GPS 设备接收数据时出现问题,python TCP - Problem receiving data from GPS device , python TCP 没有从data.head()接收熊猫的输出,而是从打印相同文件接收了输出 - Not receiving output from Pandas from data.head(), but am receiving it from print of the same file Python 没有收到来自Arduino Mega 2560 的第一行串行数据,但是收到所有后续数据,为什么会出现这种情况? - Python not receiving the first line of serial data from an Arduino Mega 2560, but receiving all subsequent data, why is this happening?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM