数据读取

source_df= pd.read_excel('EXCEL2019-06-05.xls')
打印数据,查看数据长度
print(source_df.head()) print(len(source_df))
data_ = source_df[source_df['货币代号'].isin([1])] print(len(data_)) print(data_.head())
数据读取
source_df= pd.read_excel('EXCEL2019-06-05.xls')
#通过~取反,选取不包含数字1的行
df1=source_df[~source_df['货币代号'].isin([1])]
df1.head()
dic={'A':[1,2,3,1],'B':[2,1,1,2]}
df=pd.DataFrame(dic) df
# 找出包含数值"2“的所有行(要删除的行) df[df['A'].isin([2]) | df['B'].isin([2])] # "|"表示"或”
# 删除所有包含数值"2“的行(实际上是用"~"取反得到所有不包含“2的行) df[~(df['A'].isin([2]) | df['B'].isin([2]))]
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。