Python Pandas Visualisation Assignment
Python Pandas Visualisation Assignment
Python Pandas Visualisation Assignment
Q2. Give two examples of visualisation that we come across in our daily lives.
Ans. Traffic symbols, ultrasound reports, Atlas book of maps, speedometer of a vehicle, tuners of
instruments are examples of visualisation that we come across in our daily lives.
Q8. Which function is used to display the figure created using the plot() function?
Ans. show()
Q9. Write the statements in python to plot line chart “Name” vs “Quantity” with the following
data.
Name = [“Keyboard”, “RAM”, “Mouse”] and
Quantity = [10, 7, 20]
Ans.
Q10. Write two ways of saving the chart or figure created in python using pyplot.
Ans. Two ways are:
1. We can click on the save button on the output window and save the plot as an image.
2. A figure can also be saved by using savefig() function.
Q13. Which pyplot functions are used to customise the following components of plot?
1. To add legend
2. To add title
3. To add label of X-axis
4. To add label of Y-axis
5. To add grid lines
Ans.
Function Name
To add legend legend( )
To add title title( )
To add label of X-axis xlabel( )
To add label of Y-axis ylabel( )
To add grid lines grid( )
Q17. Which colour is represented by the following alphabets in the colour attributes of plot()
function?
1. ‘b’
2. ‘m’
3. ‘k’
4. ‘c’
Ans.
Character Colour
‘b’ Blue
‘m’ Magenta
‘k’ Black
‘c’ Cyan
Q18. Which attribute of plot() function are used to change the width and the style of the line
chart?
Ans. linewidth and linestyle attribute of plot() function are used to change the width and the style of
the line chart respectively.
Q19. Linewidth is specified in _________________. The default line width is _____________ pixel showing
a thin line.
Ans. Pixel, One
Q20. Write any four string values that linestyle parameter of plot() function can take.
Ans. Four values of linestyle parameter are:
1. “solid”
2. “dotted”
3. “dashed”
4. “dashdot”
Q21. Write a statement to call the plot( ) function of a Series object ‘S1’.
Ans. S1.plot( )
Q22. ‘kind’ attribute of plot( ) function accepts string values indicating the type of plot formed?
Name any four such string values.
Ans. Values are
1. line
2. bar
3. hist
4. barh
Q24. What are some of the major components of any graphs or plot?
Ans. Major components of graphs are:
1. Chart Title
2. X-axis
3. Y-axis
4. X – axis Title
5. Y – axis Title
6. Legend
Q26. What is open data? Name any two websites from which we can download open data.
Ans. Data which is freely available for anyone to download and do analysis, primarily for educational
purposes. These are called Open Data as the data source is open to the public.
Q27. Dhriti wants to plot a line chart based on the given data to view the changing weekly
average temperature for four weeks. Help her to write the code in Python. Also give
appropriate chart title and axis titles.
Week = [1, 2, 3, 4]
Temp = [30, 34, 28, 32]
Ans.
Ans.
Q30. Write python code to plot bar chart for Class wise result analysis as shown below. Give
appropriate Chart title and axes labels.
Ans.
Ans.
Ans.
Ans.
Q35. Ananya stored the following data in a csv file named data.csv.
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv("data.csv", usecols=['Month', '2018', '2021'])
df.plot(kind='line', x='Month', color=['red', 'blue'])
plt.title('Year-Wise Sales')
plt.xlabel('Months')
plt.ylabel('Sales')
plt.show()
Q36. Parth is a student of class XII. He wants to represent the following data in the bar chart
with label “Fruit Name” on X-axis and “Monthly Expenditure” on Y-axis. He wants that edge
color of the bar should be “red”. Help him to write the code.
Fruits Monthly Expenditure(Rs)
Banana 300
Apple 600
Grapes 500
Papaya 740
Melon 450
Ans.
Ans.
Q38. Sudha is working in a multinational company. She has to present the following data in line
chart with the following specification.
Ans.
Ans.
Q40. Suman is a data analyst. She has the following data in a csv file named “year.csv”. Her boss
asked Suman to represent data in the form of bar chart. Help her in reading csv file and in
creating bar chart with the following specification.
Q41. Anant is working as a Data Analyst in a company named “”Compu-Tech”. He stored the
following data in a file named “emp.csv”. He wants to present “Department” (First Column) and
“No_of_Emp” (Third Column) in a bar chart. Help him to write the code.
Ans.
Ans.
Ans.