Python小技巧
刚刚学习python,遇到一些常见重复的问题,记录下来,以后使用。
1. Null in Pandas: pd.isnull, pd.notnull
2. Unique values in list:
list(set(mylist))
3. pandas rbind the DataFrames:
p3 = p1.append(p2,ignore_index=True)
4. drop duplicate columns in pandas:
df.drop_duplicates(cols='A',take_last=True)
5. pandas join two pandas
concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None,..)
merge(left,right,how='inner', on=None, left_on=None, right_on=None,left_index=False, right_index=False, sort=True, suffixes=('_x','_y'), copy=True)
6. pandas groupby with multiply index to columns
df.groupby(['A','B','C'], as_index=False).agg({'C':...,'D':...})
7.