Forwarded from Python | Machine Learning | Coding | R
python_basics.pdf
212.3 KB
I've just compiled a set of clean and powerful Python Cheat Sheets to help beginners and intermediates speed up their coding workflow.
Whether you're brushing up on the basics or diving into data science, these sheets will save you time and boost your productivity.
Python Basics
Jupyter Notebook Tips
Importing Libraries
NumPy Essentials
Pandas Overview
Perfect for students, developers, and anyone looking to keep essential Python knowledge at their fingertips.
#Python #CheatSheets #PythonTips #DataScience #JupyterNotebook #NumPy #Pandas #MachineLearning #AI #CodingTips #PythonForBeginners
โ๏ธ 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
โค9๐6๐ฅ1
segment = sine_wave[0:51]
windowed_segment = segment * window
VI. Convolution & Correlation
โข Perform linear convolution.
sig1 = np.repeat([0., 1., 0.], 100)
sig2 = np.repeat([0., 1., 1., 0.], 100)
convolved = signal.convolve(sig1, sig2, mode='same')
โข Compute cross-correlation.
# Useful for finding delays between signals
correlation = signal.correlate(sig1, sig2, mode='full')
โข Compute auto-correlation.
# Useful for finding periodicities in a signal
autocorr = signal.correlate(sine_wave, sine_wave, mode='full')
VII. Time-Frequency Analysis
โข Compute and plot a spectrogram.
f, t_spec, Sxx = signal.spectrogram(chirp_signal, fs)
plt.pcolormesh(t_spec, f, Sxx, shading='gouraud')
plt.show()
โข Perform Continuous Wavelet Transform (CWT).
widths = np.arange(1, 31)
cwt_matrix = signal.cwt(chirp_signal, signal.ricker, widths)
โข Perform Hilbert transform to get the analytic signal.
analytic_signal = signal.hilbert(sine_wave)
โข Calculate instantaneous frequency.
instant_phase = np.unwrap(np.angle(analytic_signal))
instant_freq = (np.diff(instant_phase) / (2.0*np.pi) * fs)
VIII. Feature Extraction
โข Find peaks in a signal.
peaks, _ = signal.find_peaks(sine_wave, height=0.5)
โข Find peaks with prominence criteria.
peaks_prom, _ = signal.find_peaks(noisy_signal, prominence=1)
โข Differentiate a signal (e.g., to find velocity from position).
derivative = np.diff(sine_wave)
โข Integrate a signal.
from scipy.integrate import cumulative_trapezoid
integral = cumulative_trapezoid(sine_wave, t, initial=0)
โข Detrend a signal to remove a linear trend.
trend = np.linspace(0, 1, fs)
trended_signal = sine_wave + trend
detrended = signal.detrend(trended_signal)
IX. System Analysis
โข Define a system via a transfer function (numerator, denominator).
# Example: 2nd order low-pass filter
system = signal.TransferFunction([1], [1, 1, 1])
โข Compute the step response of a system.
t_step, y_step = signal.step(system)
โข Compute the impulse response of a system.
t_impulse, y_impulse = signal.impulse(system)
โข Compute the Bode plot of a system's frequency response.
w, mag, phase = signal.bode(system)
X. Signal Generation from Data
โข Generate a signal from a function.
t = np.linspace(0, 1, 500)
custom_signal = np.sinc(2 * np.pi * 4 * t)
โข Convert a list of values to a signal array.
my_data = [0, 1, 2, 3, 2, 1, 0, -1, -2, -1, 0]
data_signal = np.array(my_data)
โข Read signal data from a WAV file.
from scipy.io import wavfile
samplerate, data = wavfile.read('audio.wav')
โข Create a pulse train signal.
pulse_train = np.zeros(fs)
pulse_train[::100] = 1 # Impulse every 100 samples
#Python #SignalProcessing #SciPy #NumPy #DSP
โโโโโโโโโโโโโโโ
By: @DataScienceM โจ
๐ NumPy for Absolute Beginners: A Project-Based Approach to Data Analysis
๐ Category: DATA SCIENCE
๐ Date: 2025-11-04 | โฑ๏ธ Read time: 14 min read
Master NumPy for data analysis with this project-based guide for absolute beginners. Learn to build a high-performance sensor data pipeline from scratch and unlock the true speed of Python for data-intensive applications.
#NumPy #Python #DataAnalysis #DataScience
๐ Category: DATA SCIENCE
๐ Date: 2025-11-04 | โฑ๏ธ Read time: 14 min read
Master NumPy for data analysis with this project-based guide for absolute beginners. Learn to build a high-performance sensor data pipeline from scratch and unlock the true speed of Python for data-intensive applications.
#NumPy #Python #DataAnalysis #DataScience