0% found this document useful (0 votes)
4 views1 page

Practice 1 1

cours php

Uploaded by

lamia.assidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Practice 1 1

cours php

Uploaded by

lamia.assidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Practice 1 : Introduction to Dataframe

with Pandas

Objective
Write a Pandas program to create and display a DataFrame from the following
dictionary data which has index labels.

exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael',


'Matthew', 'Laura', 'Kevin', 'Jonas', "Elias", 'Myriam'],

'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan , 8, 19, 20, 16],

'attempts': [1, 3, 2, 3, 2, 3, 1, 1, np.nan ,1, 3, 2],

'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no',np.nan , 'yes', 'yes', 'yes']}

labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']

Instructions

1. Print the three first rows using head() method


2. Extract the 'name' and 'score' columns from the DataFrame.
3. Write a Pandas program to delete the 'attempts' column from the
DataFrame.
4. Add a new column "Success" : if the score is higher than 10 we will have
1 else we will have 0
5. After executing the final dataframe, export it into csv file named
"my_data"

-CODEQUEST-

You might also like