pandas库
作者:互联网
pandas中把读取到的string值转换成object类型
pd.read_csv dataFrame .head .tail() .columns .shape .dtypes
.loc[col_name] 取列
col_names = food_info.columns.tolist()
print(col_names)
gram_columns = []
for c in col_names:
if c.endswith("(g)"):
gram_columns.append(c)
gram_df = food_info[gram_columns]
print(gram_df.head(3))
dataFrame Series
归一化操作:除以最大值.max()
food_info.sort_values("xzc",inplace=True) 是新列
.pivot_table()相当于数据透视表
passenger_survival = titanic_survival.pivot_table(index="pclass",values="survived",aggfunc=np.mean)
print(passenger_survival)
#index以谁为基准 values算什么
dropna() fillna() apply() 完成转换
def generate_age_label():
if pd.isnull(age)
Series
ndarray<series<dataFrame
标签:food,pandas,names,print,col,columns,gram 来源: https://blog.csdn.net/Redback23/article/details/119339951