Update time:2019-9-18
Pandas
写文件:
df.to_csv(path,sep='\t', index=False)
df['id'].to_csv(path, header=False, index=False)
数据合并concat:
pandas.concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True)
df3= pd.concat([df1, df2, df3], axis=1, join='inner')
Dataframe
创建Dataframe:
df = pd.Dataframe(data))
df = pd.read_table('path')
df = pd.read_csv('path')
df = pd.Dataframe()
df = pd.DataFrame(columns=list_like, index=list_like2)
遍历Dataframe:
for i, s in fst.iterrows()
插入列:
fst = fst.insert(0, 'ID', fst_id)
合并行:
DataFrame.append(self, other, ignore_index=False, verify_integrity=False, sort=None)
df3 = df2.append(df1, ignore_index=True)
合并列:
DataFrame.join(self, other, on=None, how='left', lsuffix='', rsuffix='', sort=False)
数据合并merge:
DataFrame.merge(right, how='inner', on=None, left_on=None, right_on=None, left_index=False, right_index=False, sort=False, suffixes=('_x', '_y'), copy=True, indicator=False, validate=None)
剔除数据:
fst_mht = fst.drop(['BIN_END', 'N_VARIANTS', 'WEIGHTED_FST'], axis=1)
行列重排:
fst_mht = fst_mht.reindex(['ID', 'CHROM', 'BIN_START', 'MEAN_FST'], axis=1)
修改行列名:
xp_mht = xp_mht.rename(columns={"chrom": "chr", "start": "pos", "xpclr_norm": "xpclr"})
去除空值:
fst_mht = fst_mht.dropna(axis=0, how='any')
设置行名(index):
fst_mht = fst_mht.set_index('id', drop=True)
删除DataFrame:
del df
Series
剔除数据:
fst.drop(listlike, inplace=True)