Tag Archives: python for business analysts

Pandas Example – Write a Pandas program to split a given dataset, group by one column and remove those groups if all the values of a specific columns are not available

(Python Example for Beginners)   Write a Pandas program to split a given dataset, group by one column and remove those groups if all the values of a specific columns are not available. 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 a given dataset, group by one column and apply an aggregate function to few columns and another aggregate function to the rest of the columns of the dataframe

(Python Example for Beginners)   Write a Pandas program to split a given dataset, group by one column and apply an aggregate function to few columns and another aggregate function to the rest of the columns of the dataframe.   Test Data: salesman_id sale_jan sale_feb sale_mar sale_apr sale_may sale_jun 0 5002 150.50 250.50 150.50 150.50 …

Pandas Example – Write a Pandas program to split a given dataframe into groups and create a new column with count from GroupBy

(Python Example for Beginners)   Write a Pandas program to split a given dataframe into groups and create a new column with count from GroupBy.   Test Data: book_name book_type book_id 0 Book1 Math 1 1 Book2 Physics 2 2 Book3 Computer 3 3 Book4 Science 4 4 Book1 Math 1 5 Book2 Physics 2 …

Pandas Example – Write a Pandas program to split the following dataframe into groups based on all columns and calculate GroupBy value counts on the dataframe

(Python Example for Beginners)   Write a Pandas program to split the following dataframe into groups based on all columns and calculate GroupBy value counts on the dataframe.   Test Data: id type book 0 1 10 Math 1 2 15 English 2 1 11 Physics 3 1 20 Math 4 2 21 English 5 …

Pandas Example – Write a Pandas program to split the following dataframe into groups and calculate monthly purchase amount

(Python Example for Beginners)   Write a Pandas program to split the following dataframe into groups and calculate monthly purchase amount.   Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 05-10-2012 3001 5002 1 70009 270.65 09-10-2012 3001 5005 2 70002 65.26 05-10-2012 3005 5001 3 70004 110.50 08-17-2012 3001 5003 4 70007 …

Pandas Example – Write a Pandas program to split a dataset to group by two columns and then sort the aggregated results within the groups

(Python Example for Beginners)   Write a Pandas program to split a dataset to group by two columns and then sort the aggregated results within the groups. In the following dataset group on ‘customer_id’, ‘salesman_id’ and then sort sum of purch_amt within the groups Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 2012-10-05 …

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 single column and multiple columns. Find the size of the grouped data

(Python Example for Beginners)   Write a Pandas program to split the following given dataframe into groups based on single column and multiple columns. Find the size of the grouped data.   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 …

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 …