1使用pandas的read_csv函数获取phonescsv、itheima_bookstxt文件中的数据;2使用pandas的read_excel函数获取Athletes_infoxlsx文件中的数据;3使用pandas的read_json函数获取Animal_speciesjson文件中的数据;4使用pandas的read_html函数读取httpswwwtiobecomtiobe-inde
1)使用pandas的read_csv()函数获取phones.csv、itheima_books.txt文件中的数据:
读取phones.csv文件:
import pandas as pd
phones_df = pd.read_csv('phones.csv')
读取itheima_books.txt文件:
itheima_books_df = pd.read_csv('itheima_books.txt', sep='\t')
2)使用pandas的read_excel()函数获取Athletes_info.xlsx文件中的数据:
athletes_df = pd.read_excel('Athletes_info.xlsx')
3)使用pandas的read_json()函数获取Animal_species.json文件中的数据:
animal_species_df = pd.read_json('Animal_species.json')
4)使用pandas的read_html()函数读取https://www.tiobe.com/tiobe-index/网站中历年最佳编程语言排行榜数据:
tables = pd.read_html('https://www.tiobe.com/tiobe-index/') tiobe_ranking_df = tables[0] # 获取第一个表格的数
原文地址: https://www.cveoy.top/t/topic/drml 著作权归作者所有。请勿转载和采集!