Python Data Science Jobs & Interviews
20.4K subscribers
188 photos
4 videos
25 files
327 links
Your go-to hub for Python and Data Science—featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
NUMPY FOR DS.pdf
4.5 MB
Let's start at the top...

NumPy contains a broad array of functionality for fast numerical & mathematical operations in Python

The core data-structure within #NumPy is an ndArray (or n-dimensional array)

Behind the scenes - much of the NumPy functionality is written in the programming language C

NumPy functionality is used in other popular #Python packages including #Pandas, #Matplotlib, & #scikitlearn!

✉️ Our Telegram channels: https://t.iss.one/addlist/0f6vfFbEMdAwODBk
Please open Telegram to view this post
VIEW IN TELEGRAM
1👍1
🚀 Comprehensive Guide: How to Prepare for a Data Analyst Python Interview – 350 Most Common Interview Questions

Are you ready: https://hackmd.io/@husseinsheikho/pandas-interview

#DataAnalysis #PythonInterview #DataAnalyst #Pandas #NumPy #Matplotlib #Seaborn #SQL #DataCleaning #Visualization #MachineLearning #Statistics #InterviewPrep


✉️ Our Telegram channels: https://t.iss.one/addlist/0f6vfFbEMdAwODBk

📱 Our WhatsApp channel: https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Please open Telegram to view this post
VIEW IN TELEGRAM
3
⁉️ Interview question
What happens when you call `plt.plot()` without specifying a figure or axes, and then immediately call `plt.show()`?

The function `plt.plot()` automatically creates a new figure and axes if none exist, and `plt.show()` displays the current figure. However, if multiple plots are created without clearing the figure, they may overlap or appear in unexpected orders due to matplotlib's internal state management. This behavior can lead to confusion, especially when working with loops or subplots.

#️⃣ tags: #matplotlib #python #datavisualization #plotting #beginner #codingchallenge

By: @DataScienceQ 🚀
⁉️ Interview question
How does `plt.subplot()` differ from `plt.subplots()` when creating a grid of plots?

`plt.subplot()` creates a single subplot in a grid by specifying row and column indices, requiring separate calls for each subplot. In contrast, `plt.subplots()` creates the entire grid at once, returning both the figure and an array of axes objects, making it more efficient for managing multiple subplots. However, using `plt.subplot()` can lead to overlapping or misaligned plots if not carefully managed, especially when adding elements like titles or labels.

#️⃣ tags: #matplotlib #python #plotting #subplots #datavisualization #beginner #codingchallenge

By: @DataScienceQ 🚀
#matplotlib #python #programming #question #visualization #intermediate

Write a Python program using matplotlib to perform the following tasks:

1. Generate two arrays: x from 0 to 10 with 100 points, and y = sin(x) + 0.5 * cos(2x).
2. Create a figure with two subplots arranged vertically.
3. In the first subplot, plot y vs x as a line graph with red color and marker 'o'.
4. In the second subplot, create a histogram of the y values with 20 bins.
5. Add titles, labels, and grid to both subplots.
6. Adjust the layout and save the figure as 'output_plot.png'.

import numpy as np
import matplotlib.pyplot as plt

# 1. Generate data
x = np.linspace(0, 10, 100)
y = np.sin(x) + 0.5 * np.cos(2 * x)

# 2. Create figure with two subplots
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 10))

# 3. First subplot - line plot
ax1.plot(x, y, color='red', marker='o', linestyle='-', linewidth=2)
ax1.set_title('sin(x) + 0.5*cos(2x)')
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax1.grid(True)

# 4. Second subplot - histogram
ax2.hist(y, bins=20, color='blue', alpha=0.7)
ax2.set_title('Histogram of y values')
ax2.set_xlabel('y')
ax2.set_ylabel('Frequency')
ax2.grid(True)

# 5. Adjust layout
plt.tight_layout()

# 6. Save the figure
plt.savefig('output_plot.png')

print("Plot saved as 'output_plot.png'")

Note: This code generates a sine wave with an added cosine component, creates a line plot and histogram of the data in separate subplots, adds appropriate labels and grids, and saves the resulting visualization.

By: @DataScienceQ 🚀
🧠 Quiz: Which submodule of Matplotlib is commonly imported with the alias plt to create plots and visualizations?

A) matplotlib.animation
B) matplotlib.pyplot
C) matplotlib.widgets
D) matplotlib.cm

Correct answer: B

Explanation: matplotlib.pyplot is the most widely used module in Matplotlib, providing a convenient, MATLAB-like interface for creating a variety of plots and charts. It's standard practice to import it as import matplotlib.pyplot as plt.

#Matplotlib #Python #DataVisualization

━━━━━━━━━━━━━━━
By: @DataScienceQ
2🔥1