一.使用loc时astype转化不了类型,如下图所示
二.使用协方差和相关系数矩阵函数时,无法自动跳过非int或者float类型的数据,执行不了,报错
谢谢各位大_神解惑
有人吗
不知道你这个问题是否已经解决, 如果还没有解决的话:1、loc 不仅可以输入数字也可以直接column名字,注意先行后列
df.loc[[0, 1, 10, 100], ['country', 'province', 'region_1', 'region_2']]
表示index(行)为0,1,10,100,列名为'country', 'province', 'region_1', 'region_2'。
2、
df.loc[df.country=='Italy']
选取country 列全是‘Italy’的数据
3、这两种写法等同,注意isin()的用法
df_final = df[df.country.isin(["Italy", "France"]) & (df.points >= 90)].country
df = df[df.points>=90]
df_final = (df.loc[df.country.isin(['France','Italy']),'country'])