Informatics Practices
Complete the given Python code to get the required output as: Rajasthan
import ............... as pd
di = { 'Corbett' : 'Uttarakhand', 'Sariska ' : 'Rajasthan', 'Kanha' :
'Madhya Pradesh', 'Gir' : 'Gujarat ' }
NP = ............... . Series( ............... )
print(NP[ ............... ])
Python Pandas
7 Likes
Answer
import pandas as pd
di = { 'Corbett' : 'Uttarakhand', 'Sariska' : 'Rajasthan', 'Kanha' :
'Madhya Pradesh', 'Gir' : 'Gujarat' }
NP = pd. Series(di)
print(NP['Sariska'])
Output
Rajasthan
Explanation
import pandas as pd: This line imports the pandas library and assign it the aliaspd.NP = pd.Series(di): This line creates a pandas Series objectNPfrom the dictionarydi.print(NP['Sariska']): This line accesses the value associated with the key 'Sariska' in the Series objectNPand print it. Since the value is 'Rajasthan', it gets printed.
Answered By
2 Likes
Related Questions
Predict the output of the given Python code :
import pandas as pd list1 = [-10, -20, -30] ser = pd.Series(list1 * 2) print(ser)Differentiate between the active digital footprint and passive digital footprints.
What are aggregate functions in SQL? Name any two.
Based on the SQL table CAR_SALES, write suitable queries for the following :
NUMBER SEGMENT FUEL QT1 QT2 1 Compact HatchBack Petrol 56000 70000 2 Compact HatchBack Diesel 34000 40000 3 MUV Petrol 33000 35000 4 MUV Diesel 14000 15000 5 SUV Petrol 27000 54000 6 SUV Diesel 18000 30000 7 Sedan Petrol 8000 10000 8 Sedan Diesel 1000 5000 (i) Display fuel wise average sales in the first quarter.
(ii) Display segment wise highest sales in the second quarter.
(iii) Display the records in the descending order of sales in the second quarter.