dataframe 选取某几列
import pandas as pd
df = pd.DataFrame({‘a’:[3,2,4,5,6],’b’:range(5,10)})
df[[‘a’]]
取df的feature和label
df[df.columns[:-1]]
注意取一列默认为series
df[df.columns[-1]]
group by
df_user.sexes.value_counts()
dataframe to excel
df_user.to_excel(‘user.xls’,columns=[‘names’,’sexes’,’cities’,’signatures’,’remark_names’], index=False)
df_user = pd.DataFrame.from_dict(user_data)