Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从网站中提取数据_Python_Pandas_Web Scraping - Fatal编程技术网

Python 从网站中提取数据

Python 从网站中提取数据,python,pandas,web-scraping,Python,Pandas,Web Scraping,我正试图从网站中提取数据 该表有一个span标记,它扰乱了数据提取,表值与span标记连接,我想在单独的单元格中提取单元格内容和span标记,如有帮助,将不胜感激 这是密码 import pandas as pd url = "https://www.sqimway.com/lte_band.php" lte_band = pd.read_html(url) lte_band[0] 如果您有pandas 0.24+,则可以使用并映射出每个列名的唯一值 # Set a

我正试图从网站中提取数据

该表有一个span标记,它扰乱了数据提取,表值与span标记连接,我想在单独的单元格中提取单元格内容和span标记,如有帮助,将不胜感激

这是密码

import pandas as pd

url = "https://www.sqimway.com/lte_band.php"

lte_band = pd.read_html(url)

lte_band[0]

如果您有pandas 0.24+,则可以使用并映射出每个列名的唯一值

# Set a new DataFrame variable.
df = lte_band[0]

# Note: We will have to sort on the tuple index to retain order.
df.columns = list(map(lambda q: " ".join(sorted(set(q), key = q.index)), df.columns.to_flat_index()))
df.列的输出

Index(['Band', 'Name', 'Mode', 'Downlink (MHz) Low Earfcn',
       'Downlink (MHz) Middle Earfcn', 'Downlink (MHz) High Earfcn',
       'BandwidthDL/UL (MHz)', 'Uplink (MHz) Low Earfcn',
       'Uplink (MHz) Middle Earfcn', 'Uplink (MHz) High Earfcn',
       'Duplex spacing(MHz)', 'Geographicalarea', '3GPPrelease',
       'Channel bandwidth (MHz) 1.4', 'Channel bandwidth (MHz) 3',
       'Channel bandwidth (MHz) 5', 'Channel bandwidth (MHz) 10',
       'Channel bandwidth (MHz) 15', 'Channel bandwidth (MHz) 20'],
      dtype='object')
格式:

Band
Name
Mode
Downlink (MHz) Low Earfcn
Downlink (MHz) Middle Earfcn
Downlink (MHz) High Earfcn
BandwidthDL/UL (MHz)
Uplink (MHz) Low Earfcn
Uplink (MHz) Middle Earfcn
Uplink (MHz) High Earfcn
Duplex spacing(MHz)
Geographicalarea
3GPPrelease
Channel bandwidth (MHz) 1.4
Channel bandwidth (MHz) 3
Channel bandwidth (MHz) 5
Channel bandwidth (MHz) 10
Channel bandwidth (MHz) 15
Channel bandwidth (MHz) 20