Tag Archives: Python for Citizen Data Scientist

Pandas Example – Write a Pandas program to split a given dataset using group by on multiple columns and drop last n rows of from each group

(Python Example for Beginners)   Write a Pandas program to split a given dataset using group by on multiple columns and drop last n rows of from each group.   Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 2012-10-05 3002 5002 1 70009 270.65 2012-09-10 3001 5003 2 70002 65.26 2012-10-05 3001 5001 …

Pandas Example – Write a Pandas program to split a given dataset using group by on specified column into two labels and ranges

(Python Example for Beginners)   Write a Pandas program to split a given dataset using group by on specified column into two labels and ranges. Split the group on ‘salesman_id’, Ranges: 1) (5001…5006) 2) (5007..5012)   Test Data: salesman_id sale_jan 0 5001 150.50 1 5002 270.65 2 5003 65.26 3 5004 110.50 4 5005 948.50 …

Pandas Example – Write a Pandas program to split the following datasets into groups on customer id and calculate the number of customers

(Python Example for Beginners)   Write a Pandas program to split the following datasets into groups on customer id and calculate the number of customers starting with ‘C’, the list of all products and the difference of maximum purchase amount and minimum purchase amount. Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 05-10-2012 …

Pandas Example – Write a Pandas program to split a given dataframe into groups with multiple aggregations

(Python Example for Beginners)   Write a Pandas program to split a given dataframe into groups with multiple aggregations. Split the following given dataframe by school code, class and get mean, min, and max value of height and age for each value of the school. Test Data: school class name date_Of_Birth age height weight address …

Pandas Example – Write a Pandas program to split a given dataframe into groups and list all the keys from the GroupBy object

(Python Example for Beginners)   Write a Pandas program to split a given dataframe into groups and list all the keys from the GroupBy object. Test Data: school_code class name date_Of_Birth age height weight S1 s001 V Alberto Franco 15/05/2002 12 173 35 S2 s002 V Gino Mcneill 17/05/2002 12 192 32 S3 s003 VI …

Pandas Example – Write a Pandas program to split the following dataframe into groups based on first column and set other column values into a list of values

(Python Example for Beginners)   Write a Pandas program to split the following dataframe into groups based on first column and set other column values into a list of values.   Test Data: X Y Z 0 10 10 22 1 10 15 20 2 10 11 18 3 20 20 20 4 30 21 …

Pandas Example – Write a Pandas program to split a dataset, group by one column and get mean, min, and max values by group. Using the following dataset find the mean, min, and max values of purchase amount (purch_amt) group by customer id

(Python Example for Beginners)   Write a Pandas program to split a dataset, group by one column and get mean, min, and max values by group. Using the following dataset find the mean, min, and max values of purchase amount (purch_amt) group by customer id (customer_id). Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 …

Pandas Example – Write a Pandas program to split the following given dataframe into groups based on school code and call a specific group with the name of the group

(Python Example for Beginners)   Write a Pandas program to split the following given dataframe into groups based on school code and call a specific group with the name of the group.   Test Data: school class name date_Of_Birth age height weight address S1 s001 V Alberto Franco 15/05/2002 12 173 35 street1 S2 s002 …

Pandas Example – Write a Pandas program to split the following given dataframe into groups based on school code and class

(Python Example for Beginners)   Write a Pandas program to split the following given dataframe into groups based on school code and class.   Test Data: school class name date_Of_Birth age height weight address S1 s001 V Alberto Franco 15/05/2002 12 173 35 street1 S2 s002 V Gino Mcneill 17/05/2002 12 192 32 street2 S3 …

Pandas Example – Write a Pandas program to split the following dataframe by school code and get mean, min, and max value of age for each school

(Python Example for Beginners)   Write a Pandas program to split the following dataframe by school code and get mean, min, and max value of age for each school.   Test Data: school class name date_Of_Birth age height weight address S1 s001 V Alberto Franco 15/05/2002 12 173 35 street1 S2 s002 V Gino Mcneill …