什么是df[0]在Pandas DataFrame中

2024-10-03 09:12:18 发布

您现在位置:Python中文网/ 问答频道 /正文

作为一个刚起步的学习者和学生,我正在学习一些基础知识,并开始使用pandas read_html函数,在网上搜索时,我试图通过一个包含以下代码的url从html源获取数据。在

import pandas as pd
df = pd.read_html('http://prodserverlist/pod.html', header=0, flavor='bs4')
df1 = df[0]

我想知道df[0]中的df[0]到底是什么。在


Tags: 函数代码importhttpurlpandasdfread
1条回答
网友
1楼 · 发布于 2024-10-03 09:12:18

正如我在上面的评论中提到的,df[0]只是指由pd.read_html()返回的数据帧列表(df)中的第一个数据帧(索引0),每个docs

This function searches for <table> elements and only for <tr> and <th> rows and <td> elements within each <tr> or <th> element in the table. <td> stands for “table data”.

This function will always return a list of DataFrame or it will fail, e.g., it will not return an empty list.

相关问题 更多 >