数据读取
1 |
source_df= pd.read_excel('EXCEL2019-06-05.xls') |
打印数据,查看数据长度
1 2 |
print(source_df.head()) print(len(source_df)) |
1 2 3 |
data_ = source_df[source_df['货币代号'].isin([1])] print(len(data_)) print(data_.head()) |
数据读取
1 2 3 4 |
source_df= pd.read_excel('EXCEL2019-06-05.xls') #通过~取反,选取不包含数字1的行 df1=source_df[~source_df['货币代号'].isin([1])] df1.head() |
1 |
dic={'A':[1,2,3,1],'B':[2,1,1,2]} |
1 2 |
df=pd.DataFrame(dic) df |
1 2 |
# 找出包含数值"2“的所有行(要删除的行) df[df['A'].isin([2]) | df['B'].isin([2])] # "|"表示"或” |
1 2 |
# 删除所有包含数值"2“的行(实际上是用"~"取反得到所有不包含“2的行) df[~(df['A'].isin([2]) | df['B'].isin([2]))] |