- Consider DataFrame df as shown below :
- Write command to calculate minimum value for each of the row from subset of dataframe that contains age, weight, height, runsscored
- Write command to calculate mean for last 3 rows.
- Consider the DataFrame df from above question and write the command for the following:
- Find the name of player with minimum age
- Add a new column BMI to df with value of BMI calculated as (BMI = weigth/height2).
- Consider the DataFrame:
dfd = pd.DataFrame({'Name':['Saourabh','Ram','Shyam'],'Percentage':[80,85,82]}) Write the commands for (The output should display a single value): i) Count the number of Names in dfd ii) Find the minimum percentage Marks
- What is use of reindex_like() function explain with example and Output.
- What will be the output of the following python code:
import pandas as pd import numpy as np d = {'Student':['Ali','Ali','Tom','Tom'],\ 'House':['Red',Red,'Blue',Blue’],\ 'Points':[50,70,60,80]} df =pd.DataFrame(d) df1 = df.pivot_table(index='Student',columns='House',values=’Points’,aggfunc=np.sum) print(df1)
-
Write a python statement to fill in the blanks so that the given output of is achieved:
import pandas as pd import numpy as np d = {'Rollno':[101,102,103,104], 'ECO':[70,80,50,80],'BST':[60,50,60,90]} df = pd.DataFrame(d) df1 = ___________________________ print(df1) Output: Rollno 410 ECO 280 BST 260 dtype: int64
- Write a python code to create a dataframe with appropriate headings from the list given below :
['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105','Gundaho', 82] - How does dataframe specify indexes to its data rows?
- if a datframe has following values the what will be the output of different statements:
Max speed shield Viper 1 2 cobra 4 5 Sidevinder 7 8 - df.loc['viper']
- df.loc['cobra':'viper', 'max_speed']
name
|
age
|
weight
|
height
|
runsscored
|
|
0
|
mayur
|
15
|
51
|
5.1
|
55
|
1
|
anil
|
16
|
48
|
5.2
|
25
|
2
|
viraj
|
17
|
49
|
5.1
|
71
|
3
|
viraj
|
17
|
51
|
5.3
|
53
|
4
|
mahesh
|
16
|
48
|
5.1
|
51
|
5
|
viraj
|
17
|
59
|
5.3
|
50
|
where is ans
ReplyDeleteThese question is for your practice. Solve the questions and comment your answers.
DeleteCan you pls give the answer.
ReplyDelete