湖南做防水堵漏工程商网站,网站程序源代码,酒店网站建设项目报告书,陕西专业网站开发联系电话数据统计与数据分组 1. 知识点1.18 分箱与统计个数1.19 分组与求和统计1.20 分组获取最小值1.21 分组获取值个数1.22 分组与条件查询1.23 分组与条件查询及获取最大值1.24 分组及自定义函数1.25 分组lambda函数统计 2. 题目2.18 按分类统计薪水#xff08;数据统计#xff09… 数据统计与数据分组 1. 知识点1.18 分箱与统计个数1.19 分组与求和统计1.20 分组获取最小值1.21 分组获取值个数1.22 分组与条件查询1.23 分组与条件查询及获取最大值1.24 分组及自定义函数1.25 分组lambda函数统计 2. 题目2.18 按分类统计薪水数据统计2.19 查找每个员工花费的总时间(数据分组)2.20 游戏玩法分析 I(数据分组)2.21 每位教师所教授的科目种类的数量(数据分组)2.22 超过5名学生的课(数据分组)2.23 订单最多的客户(数据分组)2.24 按日期分组销售产品(数据分组)2.25 每天的领导和合伙人(数据分组) 1. 知识点
1.18 分箱与统计个数
分箱操作# float(inf)正无穷
bins[0,20000,50001,float(inf)]
labels[Low Salary, Average Salary, High Salary]
accounts[category]pd.cut(accounts[income],binsbins,labelslabels,rightFalse)数值统计accounts_newaccounts[category].value_counts().reset_index()1.19 分组与求和统计
分组统计employeesemployees.groupby([event_day,emp_id]).agg({total_time:sum}).reset_index()多种数值统计employeesemployees.groupby([event_day,emp_id]).agg(
total_add(total_time,sum),
total_mean(total_time,mean)
).reset_index()1.20 分组获取最小值
分组获取最小值activityactivity.groupby(player_id).agg(first_login(event_date,min)).reset_index()1.21 分组获取值个数
分组获取最小值teacherteacher.groupby(teacher_id).agg(cnt(subject_id,count)).reset_index()1.22 分组与条件查询
coursescourses.groupby(class).agg(counts(student,count)).reset_index() # 分组
coursescourses.query(counts5)[[class]] # 条件查询1.23 分组与条件查询及获取最大值
分组统计ordersorders.groupby(customer_number).agg(counts(order_number,count)).reset_index()最大值max_ordersorders[counts].max()条件查询resultsorders.query(fcounts{max_orders})[[customer_number]]1.24 分组及自定义函数
def get_join(x):x_listsorted(list(set(x)))return ,.join(x_list)def get_count(x):x_listset(x)return len(x_list)activitiesactivities.groupby([sell_date]).agg(num_sold(product,get_count),products(product,get_join)).reset_index()1.25 分组lambda函数统计
daily_salesdaily_sales.groupby([date_id,make_name]).agg(unique_leads(lead_id,lambda x:len(set(x))),unique_partners(partner_id,lambda x:len(set(x)))).reset_index()2. 题目
2.18 按分类统计薪水数据统计 import pandas as pddef count_salary_categories(accounts: pd.DataFrame) - pd.DataFrame:# float(inf)bins[0,20000,50001,float(inf)]labels[Low Salary, Average Salary, High Salary]accounts[category]pd.cut(accounts[income],binsbins,labelslabels,rightFalse)accounts_newaccounts[category].value_counts().reset_index()accounts_newaccounts_new.rename(columns{count:accounts_count})accounts_newaccounts_new.sort_values(category,ascendingFalse)return accounts_new2.19 查找每个员工花费的总时间(数据分组) import pandas as pddef total_time(employees: pd.DataFrame) - pd.DataFrame:# pandas流employeesemployees.assign(total_time employees.out_time-employees.in_time).groupby([event_day,emp_id]).agg({total_time:sum}).reset_index().rename(columns {event_day:day})# employees[total_time]employees[out_time]-employees[in_time]# employeesemployees.groupby([event_day,emp_id])[total_time].sum().reset_index()# employeesemployees.rename(columns{event_day:day})# employees.sort_values(emp_id,inplaceTrue)return employees2.20 游戏玩法分析 I(数据分组) import pandas as pddef game_analysis(activity: pd.DataFrame) - pd.DataFrame:activityactivity.groupby(player_id).agg(first_login(event_date,min)).reset_index()return activity2.21 每位教师所教授的科目种类的数量(数据分组) import pandas as pddef count_unique_subjects(teacher: pd.DataFrame) - pd.DataFrame:teacher.drop_duplicates([teacher_id,subject_id],inplaceTrue)teacherteacher.groupby(teacher_id).agg(cnt(subject_id,count)).reset_index()return teacher2.22 超过5名学生的课(数据分组) import pandas as pddef find_classes(courses: pd.DataFrame) - pd.DataFrame:coursescourses.groupby(class).agg(counts(student,count)).reset_index()return courses.query(counts5)[[class]]2.23 订单最多的客户(数据分组) import pandas as pddef largest_orders(orders: pd.DataFrame) - pd.DataFrame:ordersorders.groupby(customer_number).agg(counts(order_number,count)).reset_index()max_ordersorders[counts].max()resultsorders.query(fcounts{max_orders})[[customer_number]]return results2.24 按日期分组销售产品(数据分组) import pandas as pddef categorize_products(activities: pd.DataFrame) - pd.DataFrame:activitiesactivities.groupby([sell_date]).agg(num_sold(product,lambda x:len(set(x))),products(product,lambda x:,.join(sorted(list(set(x)))))).reset_index()return activities
2.25 每天的领导和合伙人(数据分组) import pandas as pddef daily_leads_and_partners(daily_sales: pd.DataFrame) - pd.DataFrame:daily_salesdaily_sales.groupby([date_id,make_name]).agg(unique_leads(lead_id,lambda x:len(set(x))),unique_partners(partner_id,lambda x:len(set(x)))).reset_index()return daily_sales
文章转载自: http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn http://www.morning.wrdlf.cn.gov.cn.wrdlf.cn http://www.morning.zhnpj.cn.gov.cn.zhnpj.cn http://www.morning.jbtlf.cn.gov.cn.jbtlf.cn http://www.morning.shxrn.cn.gov.cn.shxrn.cn http://www.morning.pqndg.cn.gov.cn.pqndg.cn http://www.morning.lpcct.cn.gov.cn.lpcct.cn http://www.morning.wwdlg.cn.gov.cn.wwdlg.cn http://www.morning.nhzps.cn.gov.cn.nhzps.cn http://www.morning.kskpx.cn.gov.cn.kskpx.cn http://www.morning.nqfxq.cn.gov.cn.nqfxq.cn http://www.morning.hhboyus.cn.gov.cn.hhboyus.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn http://www.morning.tkzqw.cn.gov.cn.tkzqw.cn http://www.morning.bsqbg.cn.gov.cn.bsqbg.cn http://www.morning.yrbhf.cn.gov.cn.yrbhf.cn http://www.morning.trjr.cn.gov.cn.trjr.cn http://www.morning.jwskq.cn.gov.cn.jwskq.cn http://www.morning.rnht.cn.gov.cn.rnht.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.nkjnr.cn.gov.cn.nkjnr.cn http://www.morning.qzsmz.cn.gov.cn.qzsmz.cn http://www.morning.fnrkh.cn.gov.cn.fnrkh.cn http://www.morning.fwcjy.cn.gov.cn.fwcjy.cn http://www.morning.jgzmr.cn.gov.cn.jgzmr.cn http://www.morning.wknjy.cn.gov.cn.wknjy.cn http://www.morning.zfqr.cn.gov.cn.zfqr.cn http://www.morning.qrwjb.cn.gov.cn.qrwjb.cn http://www.morning.rqhdt.cn.gov.cn.rqhdt.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.nydtt.cn.gov.cn.nydtt.cn http://www.morning.rlsd.cn.gov.cn.rlsd.cn http://www.morning.lgnz.cn.gov.cn.lgnz.cn http://www.morning.kpxky.cn.gov.cn.kpxky.cn http://www.morning.kxryg.cn.gov.cn.kxryg.cn http://www.morning.yxgqr.cn.gov.cn.yxgqr.cn http://www.morning.dppfh.cn.gov.cn.dppfh.cn http://www.morning.gcftl.cn.gov.cn.gcftl.cn http://www.morning.qxdrw.cn.gov.cn.qxdrw.cn http://www.morning.ylpl.cn.gov.cn.ylpl.cn http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn http://www.morning.qrlkt.cn.gov.cn.qrlkt.cn http://www.morning.mzcsp.cn.gov.cn.mzcsp.cn http://www.morning.kdfqx.cn.gov.cn.kdfqx.cn http://www.morning.frzdt.cn.gov.cn.frzdt.cn http://www.morning.xcyhy.cn.gov.cn.xcyhy.cn http://www.morning.jpmcb.cn.gov.cn.jpmcb.cn http://www.morning.mbmtz.cn.gov.cn.mbmtz.cn http://www.morning.wrdlf.cn.gov.cn.wrdlf.cn http://www.morning.mgkb.cn.gov.cn.mgkb.cn http://www.morning.bpmdz.cn.gov.cn.bpmdz.cn http://www.morning.tkzrh.cn.gov.cn.tkzrh.cn http://www.morning.xnnpy.cn.gov.cn.xnnpy.cn http://www.morning.pfnrj.cn.gov.cn.pfnrj.cn http://www.morning.cjwkf.cn.gov.cn.cjwkf.cn http://www.morning.glxmf.cn.gov.cn.glxmf.cn http://www.morning.yxmcx.cn.gov.cn.yxmcx.cn http://www.morning.wqbzt.cn.gov.cn.wqbzt.cn http://www.morning.qlpq.cn.gov.cn.qlpq.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.tynqy.cn.gov.cn.tynqy.cn http://www.morning.fwrr.cn.gov.cn.fwrr.cn http://www.morning.nkyqh.cn.gov.cn.nkyqh.cn http://www.morning.txfxy.cn.gov.cn.txfxy.cn http://www.morning.qrzqd.cn.gov.cn.qrzqd.cn http://www.morning.ykxnp.cn.gov.cn.ykxnp.cn http://www.morning.rsnd.cn.gov.cn.rsnd.cn http://www.morning.lveyue.com.gov.cn.lveyue.com http://www.morning.mrnnb.cn.gov.cn.mrnnb.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.ndxmn.cn.gov.cn.ndxmn.cn http://www.morning.fbmrz.cn.gov.cn.fbmrz.cn http://www.morning.wbxbj.cn.gov.cn.wbxbj.cn http://www.morning.csnch.cn.gov.cn.csnch.cn http://www.morning.jqbpn.cn.gov.cn.jqbpn.cn http://www.morning.hptbp.cn.gov.cn.hptbp.cn http://www.morning.zrgsg.cn.gov.cn.zrgsg.cn http://www.morning.jsrnf.cn.gov.cn.jsrnf.cn http://www.morning.bchgl.cn.gov.cn.bchgl.cn