df.reset_index(drop=True)
R解法
rownames(df) <- NULL
# 如果是tibble则索引始终是按顺序
备注
有时我们修改数据会导致索引混乱
65
异常值处理
题目:删除所有换手率为非数字的行...is.na(as.numeric(df$`换手率(%)`)),]
# 或者根据前几题的经验,非数字就是'--'
df %
filter(`换手率(%)` !...= 2,
col3 = 3)
# 或者用类似pandas的方法
names(df) <- c('col1','col2','col3')
89
数据提取
题目:提取第一列中不在第二列出现的数字...(df$col1 %in% df$col2),1]
90
数据提取
题目:提取第一列和第二列出现频率最高的三个数字
难度:⭐⭐⭐
Python解法
temp = df['col1'].append(df...select(col3,col2,everything())
94
数据提取
题目:提取第一列位置在1,10,15的数字
难度:⭐⭐
Python解法
df['col1'].take([1,10,15