当前位置: 首页 > news >正文

营销型企业网站核心网站建设的软件是哪个

营销型企业网站核心,网站建设的软件是哪个,长春网站策划,低价网站建设资讯文章目录 14.4 USDA Food Database#xff08;美国农业部食品数据库#xff09; 14.4 USDA Food Database#xff08;美国农业部食品数据库#xff09; 这个数据是关于食物营养成分的。存储格式是JSON#xff0c;看起来像这样#xff1a; {id: 21441, 美国农业部食品数据库 14.4 USDA Food Database美国农业部食品数据库 这个数据是关于食物营养成分的。存储格式是JSON看起来像这样 {id: 21441, description: KENTUCKY FRIED CHICKEN, Fried Chicken, EXTRA CRISPY, Wing, meat and skin with breading, tags: [KFC], manufacturer: Kentucky Fried Chicken, group: Fast Foods, portions: [ { amount: 1, unit: wing, with skin, grams: 68.0}...],nutrients: [ { value: 20.8, units: g, description: Protein, group: Composition },...] } 每种食物都有一系列特征其中有两个listprotions和nutrients。我们必须把这样的数据进行处理方便之后的分析。 这里使用python内建的json模块 import pandas as pd import numpy as np import jsonpd.options.display.max_rows 10db json.load(open(../datasets/usda_food/database.json)) len(db)6636db[0].keys()dict_keys([manufacturer, description, group, id, tags, nutrients, portions])db[0][nutrients][0]{description: Protein,group: Composition,units: g,value: 25.18}nutrients pd.DataFrame(db[0][nutrients]) nutrientsdescriptiongroupunitsvalue0ProteinCompositiong25.1801Total lipid (fat)Compositiong29.2002Carbohydrate, by differenceCompositiong3.0603AshOtherg3.2804EnergyEnergykcal376.000...............157SerineAmino Acidsg1.472158CholesterolOthermg93.000159Fatty acids, total saturatedOtherg18.584160Fatty acids, total monounsaturatedOtherg8.275161Fatty acids, total polyunsaturatedOtherg0.830 162 rows × 4 columns 当把由字典组成的list转换为DataFrame的时候我们可以吹创业提取的list部分。这里我们提取食品名群groupID制造商 info_keys [description, group, id, manufacturer] info pd.DataFrame(db, columnsinfo_keys) info[:5]descriptiongroupidmanufacturer0Cheese, carawayDairy and Egg Products10081Cheese, cheddarDairy and Egg Products10092Cheese, edamDairy and Egg Products10183Cheese, fetaDairy and Egg Products10194Cheese, mozzarella, part skim milkDairy and Egg Products1028 info.info()class pandas.core.frame.DataFrame RangeIndex: 6636 entries, 0 to 6635 Data columns (total 4 columns): description 6636 non-null object group 6636 non-null object id 6636 non-null int64 manufacturer 5195 non-null object dtypes: int64(1), object(3) memory usage: 207.5 KB我们可以看到食物群的分布使用value_counts: pd.value_counts(info.group)[:10]Vegetables and Vegetable Products 812 Beef Products 618 Baked Products 496 Breakfast Cereals 403 Legumes and Legume Products 365 Fast Foods 365 Lamb, Veal, and Game Products 345 Sweets 341 Pork Products 328 Fruits and Fruit Juices 328 Name: group, dtype: int64这里我们对所有的nutrient数据做一些分析把每种食物的nutrient部分组合成一个大表格。首先把每个食物的nutrient列表变为DataFrame添加一列为id然后把id添加到DataFrame中接着使用concat联结到一起 # 先创建一个空DataFrame用来保存最后的结果 # 这部分代码运行时间较长请耐心等待 nutrients_all pd.DataFrame()for food in db:nutrients pd.DataFrame(food[nutrients])nutrients[id] food[id]nutrients_all nutrients_all.append(nutrients, ignore_indexTrue)译者虽然作者在书中说了用concat联结在一起但我实际测试后这个concat的方法非常耗时用时几乎是append方法的两倍所以上面的代码中使用了append方法。 一切正常的话出来的效果是这样的 nutrients_alldescriptiongroupunitsvalueid0ProteinCompositiong25.18010081Total lipid (fat)Compositiong29.20010082Carbohydrate, by differenceCompositiong3.06010083AshOtherg3.28010084EnergyEnergykcal376.0001008..................389350Vitamin B-12, addedVitaminsmcg0.00043546389351CholesterolOthermg0.00043546389352Fatty acids, total saturatedOtherg0.07243546389353Fatty acids, total monounsaturatedOtherg0.02843546389354Fatty acids, total polyunsaturatedOtherg0.04143546 389355 rows × 5 columns 这个DataFrame中有一些重复的部分看一下有多少重复的行 nutrients_all.duplicated().sum() # number of duplicates14179把重复的部分去掉 nutrients_all nutrients_all.drop_duplicates() nutrients_alldescriptiongroupunitsvalueid0ProteinCompositiong25.18010081Total lipid (fat)Compositiong29.20010082Carbohydrate, by differenceCompositiong3.06010083AshOtherg3.28010084EnergyEnergykcal376.0001008..................389350Vitamin B-12, addedVitaminsmcg0.00043546389351CholesterolOthermg0.00043546389352Fatty acids, total saturatedOtherg0.07243546389353Fatty acids, total monounsaturatedOtherg0.02843546389354Fatty acids, total polyunsaturatedOtherg0.04143546 375176 rows × 5 columns 为了与info_keys中的group和descripton区别开我们把列名更改一下 col_mapping {description: food,group: fgroup}info info.rename(columnscol_mapping, copyFalse) info.info()class pandas.core.frame.DataFrame RangeIndex: 6636 entries, 0 to 6635 Data columns (total 4 columns): food 6636 non-null object fgroup 6636 non-null object id 6636 non-null int64 manufacturer 5195 non-null object dtypes: int64(1), object(3) memory usage: 207.5 KBcol_mapping {description : nutrient,group: nutgroup}nutrients_all nutrients_all.rename(columnscol_mapping, copyFalse) nutrients_allnutrientnutgroupunitsvalueid0ProteinCompositiong25.18010081Total lipid (fat)Compositiong29.20010082Carbohydrate, by differenceCompositiong3.06010083AshOtherg3.28010084EnergyEnergykcal376.0001008..................389350Vitamin B-12, addedVitaminsmcg0.00043546389351CholesterolOthermg0.00043546389352Fatty acids, total saturatedOtherg0.07243546389353Fatty acids, total monounsaturatedOtherg0.02843546389354Fatty acids, total polyunsaturatedOtherg0.04143546 375176 rows × 5 columns 上面所有步骤结束后我们可以把info和nutrients_all合并merge ndata pd.merge(nutrients_all, info, onid, howouter) ndata.info()class pandas.core.frame.DataFrame Int64Index: 375176 entries, 0 to 375175 Data columns (total 8 columns): nutrient 375176 non-null object nutgroup 375176 non-null object units 375176 non-null object value 375176 non-null float64 id 375176 non-null int64 food 375176 non-null object fgroup 375176 non-null object manufacturer 293054 non-null object dtypes: float64(1), int64(1), object(6) memory usage: 25.8 MBndata.iloc[30000]nutrient Glycine nutgroup Amino Acids units g value 0.04 id 6158 food Soup, tomato bisque, canned, condensed fgroup Soups, Sauces, and Gravies manufacturer Name: 30000, dtype: object我们可以对食物群food group和营养类型nutrient type分组后对中位数进行绘图 result ndata.groupby([nutrient, fgroup])[value].quantile(0.5)%matplotlib inlineresult[Zinc, Zn].sort_values().plot(kindbarh, figsize(10, 8))我们还可以找到每一种营养成分含量最多的食物是什么 by_nutrient ndata.groupby([nutgroup, nutrient])get_maximum lambda x: x.loc[x.value.idxmax()] get_minimum lambda x: x.loc[x.value.idxmin()]max_foods by_nutrient.apply(get_maximum)[[value, food]]# make the food a little smaller max_foods.food max_foods.food.str[:50]因为得到的DataFrame太大这里只输出Amino Acids(氨基酸)的营养群nutrient group: max_foods.loc[Amino Acids][food]nutrient Alanine Gelatins, dry powder, unsweetened Arginine Seeds, sesame flour, low-fat Aspartic acid Soy protein isolate Cystine Seeds, cottonseed flour, low fat (glandless) Glutamic acid Soy protein isolate... Serine Soy protein isolate, PROTEIN TECHNOLOGIES INTE... Threonine Soy protein isolate, PROTEIN TECHNOLOGIES INTE... Tryptophan Sea lion, Steller, meat with fat (Alaska Native) Tyrosine Soy protein isolate, PROTEIN TECHNOLOGIES INTE... Valine Soy protein isolate, PROTEIN TECHNOLOGIES INTE... Name: food, Length: 19, dtype: object
http://www.ho-use.cn/article/10815273.html

相关文章:

  • 长沙 网站建设公司030159网站建设与维护
  • 设计师分享网站最大的免费网站建设
  • 在百度做网站推广怎么做wordpress音乐主题免费
  • 集团网站建设服务做网页需要学什么语言
  • 如何搭建一个公司网站站长工具国产2023
  • 深圳网站优化方案wordpress自动分享插件
  • 广西网站建开发一个app收费
  • 九江网站设计公司seo搜索排名优化公司
  • 天津做网站建设公司南昌品牌网站建设
  • 建设网站设计的公司网站建设的税收编码
  • php做网站项目的流程什么软件可以看到街景
  • 下沙做网站青岛做商城网站
  • 江西网站开发方案wordpress的图标怎么添加
  • wordpress网站的搭建在线设计房屋装修
  • 白酒公司网站的建设建立新中国的构想及其实践
  • 怎么做电力设计公司网站在银行网站如何做理财风险评测
  • 1g内存的服务器可以建设几个网站烟台做网站联系电话
  • asp access网站建设源代码广西建设网网上办事大厅个人版
  • 比较大的做网站的公司有哪些百度多长时间收录网站
  • 国外做储物的网站企业建站系统官网
  • 大连网站专业制作莱芜网页制作公司
  • 全平台响应式网站建设平面ui设计网站
  • 动感网站模板生活家装饰
  • 电子商务网站建设实训报告范文肇庆建设网站
  • 菏泽做网站建设的公司哪个地方网站建设的公司多
  • 兰州网站推广建设网站建设唯特和凡科哪个好
  • 腾讯空间个人认证 企业认证 网站认证哪种功能用途最齐全??花的网页设计模板素材
  • 青岛优化网站关键词做网站公司郑州汉狮
  • 有什么网站可以做简历编写网站用什么语言
  • 网站建设与管理清考作业能打开各种网站的浏览器app