Lab10_PythonDataAnalysis
Lab10_PythonDataAnalysis
1. Creating Arrays:
o Create a 1D NumPy array with the values [5, 10, 20, 30, 40, 50].
o Create a 2D NumPy array with the following values:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
2. Array Operations:
o Multiply each element in the 1D array by 2.
o Add 5 to all elements in the 2D array.
o Perform element-wise addition (+) and multiplication (*) between the 2D array
and itself.
3. Reshape and Transpose:
Reshape:
3.1. Convert the 1D array into a 2D array with 2 rows and 3 columns.
3.2. Convert the 1D array into a 2D array with 3 rows and 2 columns.
3.3. Flatten the reshaped 2D array in step 3.1 back into a 1D array.
Transpose the 2D Array:
o Transpose the 2D array created in step 1 to switch rows and columns.
4. Accessing Elements:
o Retrieve the third element and the last element from the 1D array.
o Retrieve the element in the second row and third column of the 2D array.
5. Slicing:
o Extract the first two rows of the 2D array.
o Extract the last two elements of the 1D array.
6. Aggregation functions:
o Calculate the sum of the elements in the 1D array.
o Calculate the sum along columns for the 2D array.
o Calculate the sum along rows for the 2D array.
o Calculate the mean, maximum, and minimum of the 2D array.
Objective: Learn to work with DataFrames and perform basic data operations.
1. Loading Data:
o Create a Pandas DataFrame manually using the following data:
2. DataFrame Exploration:
o Display the header and the first two rows of the DataFrame.
o Display the header and the last row of the DataFrame.
o Display the column names and data types.
o Find the number of rows and columns in the DataFrame.
3. Data Selection:
o Retrieve the Name column.
o Retrieve rows where the Grade is greater than 12.
4. Adding a Column:
o Add a new column called Passed that indicates whether the student passed
(Grade ≥ 12).
5. Statistics:
o Calculate the average age of the students.
o Find the highest and lowest grade.
6. Saving the Data:
o Drop the column Grade and save the updated DataFrame to a CSV file named
students_updated.csv.