Q8 – Write a Query Create a DataFrame from the following
data representing student details. The columns should
be: 'StudentName', 'Class', 'Marks'. Display the
DataFrame.
Solution:
Output:
Q9 – Write a Query to display only the 'StudentName' and
'Marks' columns for students who scored more than 85.
Solution:
Output:
Q10 – Write a Query to Group the DataFrame by the 'Class'
column and calculate the average marks for each class.
Display the resulting DataFrame.
Solution:
Output:
Q11 – Write a Query to Display the rows of students who
are in Class '12B'.
Solution:
Output:
Q12 – Write a Query to Calculate and display the average
marks of all students in the DataFrame.
Solution:
Output:
Q13 – Write a Query to Create a DataFrame from the
following data and calculate the total marks for each
class by grouping the DataFrame by the 'Class' column.
Display the resulting DataFrame.
Solution:
Output:
Q14 – Write a Query to Create a DataFrame with student
data and write it to a CSV file named students.csv
without the index.
Solution:
Output:
Q15 – Write a Query to Read a CSV file named
students.csv that contains the columns 'StudentName',
'Class', and 'Marks'. Display the first 5 rows of the
DataFrame.
Solution:
Output: