0% found this document useful (0 votes)
2 views2 pages

Program Questions

The document contains a series of questions related to data manipulation and visualization using NumPy, Pandas, Matplotlib, and Seaborn. It includes tasks such as creating arrays and dataframes, performing statistical analysis, and generating various types of plots. Each section provides specific exercises aimed at enhancing skills in managing and analyzing data.

Uploaded by

Karrina Daure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Program Questions

The document contains a series of questions related to data manipulation and visualization using NumPy, Pandas, Matplotlib, and Seaborn. It includes tasks such as creating arrays and dataframes, performing statistical analysis, and generating various types of plots. Each section provides specific exercises aimed at enhancing skills in managing and analyzing data.

Uploaded by

Karrina Daure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NumPy Questions

1. Create an array of 10 zeros.


o Add 1 to every element in the array.
2. Generate a 5x5 matrix with random integers from 1 to 50.
o Find the maximum and minimum values in the matrix.
3. Create a NumPy array of shape (3, 4) filled with a sequence of numbers from 1 to 12.
o Reshape it into a 4x3 array.
4. Given a NumPy array, replace all elements greater than 10 with 10.
5. Create two arrays of size 5.
o Perform element-wise addition, subtraction, multiplication, and division.

Pandas DataFrame Questions


1. Create a DataFrame from a dictionary with 'Name', 'Age', and 'Score' as columns.
o Sort the DataFrame by 'Score' descending.
2. Read a CSV file into a DataFrame.
o Display the first 5 rows and column summary.
3. Group a DataFrame by a categorical column and compute the mean of each group.
4. Filter rows where a column value is greater than a given threshold.
5. Add a new column to the DataFrame that is a function of existing columns (e.g., total =
price × quantity).

Matplotlib Questions
1. Plot a simple line graph for y = x² for values of x from -10 to 10.
2. Create a bar chart showing sales data for 5 products.
3. Plot a sine wave using NumPy and Matplotlib.
4. Create a subplot with 2 rows and 1 column showing:
o Line chart of one function
o Bar chart of some data
5. Customize a plot with labels, title, legend, and grid.

Seaborn Questions
1. Use Seaborn to plot a histogram of a normally distributed dataset (1000 samples).
2. Plot a scatter plot with Seaborn using two columns of a Pandas DataFrame.
3. Create a box plot to visualize the distribution of scores grouped by gender.
4. Use the built-in tips dataset to plot:
o A violin plot of total bill by day.
o A swarm plot on top of a box plot.
5. Create a heatmap showing correlation between all numeric columns in a DataFrame.
Managing and Analyzing Data with NumPy
1. Create a 1D NumPy array of integers from 10 to 50.
o Find the mean, median, and standard deviation.
2. Generate a 2D array of shape (4, 5) with random integers between 0 and 100.
o Find the row-wise and column-wise maximums.
3. Load data from a CSV file using NumPy (np.genfromtxt).
o Handle missing values and compute basic statistics.
4. Count how many values in an array fall within a given range (e.g., between 20 and 40).

Transforming Data with NumPy


1. Reshape a flat array of 20 numbers into a 4×5 matrix.
2. Normalize an array so that its values range from 0 to 1.
3. Replace all values in an array greater than the mean with the mean itself.
4. Stack two arrays vertically and horizontally.
5. Use Boolean indexing to extract all even numbers from an array.

Managing and Analyzing Data with Pandas


1. Load a CSV file into a Pandas DataFrame.
o Show the first 10 rows and summary statistics.
2. Group the DataFrame by a categorical column and compute the mean of each group.
3. Filter rows where a column value exceeds a certain threshold.
4. Drop rows with missing values, then fill missing values with the column mean.
5. Create a new column from existing columns (e.g., total_price = quantity × unit_price).

Transforming and Visualizing Data with Pandas


1. Rename column names to lowercase.
2. Convert a date column to datetime and extract year/month.
3. Pivot a DataFrame to show average sales by region and product.
4. Sort the DataFrame by multiple columns (e.g., by 'region' and then by 'sales').
5. Plot a histogram, line plot, and bar chart using Pandas built-in .plot() function.

Visualizing Data with Matplotlib and Seaborn


Matplotlib
1. Plot a line graph for y = x^2 where x ranges from -10 to 10.
2. Create a bar chart showing population by country.
3. Create a subplot with 2 plots side-by-side: one line plot and one scatter plot.
4. Customize a plot with title, axis labels, legend, and gridlines.
5. Save a Matplotlib figure to a PNG file.
Seaborn
1. Use the built-in tips dataset to create a scatter plot of total_bill vs tip.
2. Create a box plot to compare distributions of a numerical column grouped by a categorical
variable (e.g., gender, day).
3. Generate a heatmap to show correlations among numerical columns.
4. Plot a violin plot to show the distribution of scores grouped by class.
5. Overlay a KDE (Kernel Density Estimate) plot on a histogram.

You might also like