Day: April 6, 2021

Pandas Example – Write a Pandas program to delete the ‘attempts’ column from the DataFrame

(Python Example for Beginners)   Write a Pandas program to delete the ‘attempts’ column from the DataFrame. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], ‘qualify’: …

Pandas Example – Write a Pandas program to replace the ‘qualify’ column contains the values ‘yes’ and ‘no’ with True and False

(Python Example for Beginners)   Write a Pandas program to replace the ‘qualify’ column contains the values ‘yes’ and ‘no’ with True and False. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, …

Pandas Example – Write a Pandas program to append a new row ‘k’ to DataFrame with given values for each column. Now delete the new row and return the original data frame

(Python Example for Beginners)   Write a Pandas program to append a new row ‘k’ to DataFrame with given values for each column. Now delete the new row and return the original data frame. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, …

Pandas Example – Write a Pandas program to calculate the mean score for each different student in data frame

(Python Example for Beginners)   Write a Pandas program to calculate the mean score for each different student in data frame. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, 2, 3, 1, …

Pandas Example – Write a Pandas program to calculate the sum of the examination attempts by the students

(Python Example for Beginners)   Write a Pandas program to calculate the sum of the examination attempts by the students. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, 2, 3, 1, 1, …

Pandas Example – Write a Pandas program to select the rows where number of attempts in the examination is less than 2 and score greater than 15

(Python Example for Beginners)   Write a Pandas program to select the rows where number of attempts in the examination is less than 2 and score greater than 15. Sample DataFrame: Sample Python dictionary data and list labels: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, …

Pandas Example – Write a Pandas program to select the rows where the score is missing, i.e. is NaN

(Python Example for Beginners)   Write a Pandas program to select the rows where the score is missing, i.e. is NaN. Sample DataFrame: Sample Python dictionary data and list labels: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: …

Pandas Example – Write a Pandas program to count the number of rows and columns of a DataFrame

(Python Example for Beginners)   Write a Pandas program to count the number of rows and columns of a DataFrame. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, 2, 3, 1, 1, …

Pandas Example – Write a Pandas program to select the rows where the number of attempts in the examination is greater than 2

(Python Example for Beginners)   Write a Pandas program to select the rows where the number of attempts in the examination is greater than 2. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, …

Pandas Example – Write a Pandas program to select the ‘name’ and ‘score’ columns from the following DataFrame

(Python Example for Beginners) Write a Pandas program to select the ‘name’ and ‘score’ columns from the following DataFrame. Sample DataFrame: exam_data = {‘name’: [‘Anastasia’, ‘Dima’, ‘Katherine’, ‘James’, ‘Emily’, ‘Michael’, ‘Matthew’, ‘Laura’, ‘Kevin’, ‘Jonas’], ‘score’: [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], ‘attempts’: [1, 3, 2, 3, 2, 3, 1, 1, 2, …