编程语言
首页 > 编程语言> > 数据挖掘算法原理与实践:数据预处理

数据挖掘算法原理与实践:数据预处理

作者:互联网

第1关:数据集介绍

import pandas as pd
f500 = pd.read_csv('f500.csv',index_col=0)
f500.index.name = None

# 请在此添加代码,分别打印f500的类型和形状大小
#********** Begin **********#
print(type(f500))
print(f500.shape)
#********** End **********#

第5关:值统计的方法

import pandas as pd
f500 = pd.read_csv('f500.csv',index_col=0)
f500.index.name = None
f500_sel = f500.iloc[[0,1,2,3,4,8]]

# 请在此添加代码
#********** Begin **********#
countries = f500_sel["country"]

country_counts = countries.value_counts()

print(countries)
print(country_counts)



#********** End **********#

第6关:通过标签从series中选择项

import pandas as pd
f500 = pd.read_csv('f500.csv',index_col=0)
f500.index.name = None
countries = f500['country']
countries_counts = countries.value_counts()

# 请在此添加代码
#********** Begin **********#
india = countries_counts["India"]
north_america = countries_counts.loc[["USA","Canada","Mexico"]]
print(india)

print(north_america)
#********** End **********#



#********** End **********#

第7关:综合挑战

#i  在educoder.net上测试不了

import pandas as pd
f500 = pd.read_csv('f500.csv',index_col=0)
f500.index.name = None

#i-------------
countries = f500['country']
countries_counts = countries.value_counts()

#india = countries_counts["India"]
#north_america = countries_counts.loc[["USA","Canada","Mexico"]]
# 请在此添加代码
#********** Begin **********#
big_movers = f500.loc[["Aviva","HP","JD.com","BHP Billiton"],["rank","previous_rank"]]
print(big_movers)

bottom_companies = f500.loc["National Grid":"AutoNation",["rank","sector","country"]]
print(bottom_companies)
#********** End **********#

标签:index,countries,print,算法,pd,数据挖掘,counts,f500,预处理
来源: https://blog.csdn.net/qq_44876636/article/details/115614897