**
一、结构化数据
**
1.遍历dataframe
for index, row in df.iterrows():
print(row[0],row[1])
2.识别空值
全为数值型:df.isnull(s)
字符串型:if type(s) == float
3.不展示序号
读取表格:pd.read_excel('', index_col=0)
写入表格:df.to_excel('', index=False)
4.dataframe索引
data.iloc[:,:] # 行号和列号
5.去除重复行/列
df.drop_duplicates() # 行
df = df.loc[:,~df.columns.duplicated()] # 删除重复列
6.换列名
df= df.rename(columns={'A':'a','B':'b'}) # 换名
7.聚合
df[‘汇总列’] = df.groupby('聚合列')[‘汇总列’].sum()
8.取偶数列、奇数列
arr = np.arange(len(data.columns)) % 2
偶数列:data.iloc[:, arr == 0]
奇数列:data.iloc[:, arr == 1]