Build Your Data Science Code Library

Organize your Data Science code snippets and speed up project development

Data Preprocessing with Pandas

IMPORT DATA
CSV
Selecting the Row that Contains The Column Header
Reading a Subset of Columns
Skipping Rows
Reading a Sample of Rows
Parsing a Date Column
EXCEL
Import an Excel Sheet
Select the Header Row
Selecting Columns to Import
Skipping Rows
Selecting the Number of Rows
Import Columns from Excel as Dates
SCRAPE DATA
Initialise a Web Scraper with Beautiful Soup
Find All Instances of a Tag with Beautiful Soup
Find the Nth Tag On a WebPage with Beautiful Soup
Get An Inner Tag Using Beautiful Soup
Get The Text Within a Tag Using Beautiful Soup
Using Selectors in Beautiful Soup to Scrape Using Classes & IDs
PREPARE DATA
CONVERTING
Efficient Data Type Minification in Python using Numpy and Pandas
Converting Data Types
CLEANING NANS
Replacing NaNs
Grouped Forward Fill & Back Fill
Fill NaNs With Values & By Series
CLEANING STRINGS
Find & Replace
Changing the Case of String Columns
Removing Whitespace or Characters
SELECTING & RENAMING
Selecting Columns Using Loc and iLoc
Dropping Columns
Renaming Columns Using Dictionaries & Lists
Selecting Rows Using iLoc
SAMPLING
Stratified Sampling
Regular Sampling
FILTERING
Filtering a Dataframe Using AND
Filtering a Dataframe Using OR
Drop Duplicate Values
Filter a DataFrame Using a List
TRANSFORM
SUMMARISE
Pivoting Dataframes
Aggregate Using GroupBy, Agg & Dictionaries
JOIN
MERGE
How to Combine or Merge Pandas Dataframe Columns
Join DataFrames Using Merge
UNION
Union Two DataFrames
FEATURE ENGINEERING
WINDOW & LAG FEATURES
Running Total
Lag Features Using Shift
Grouped Rolling Features
STRINGS
Find & Replace
Get The First & Last N Characters
DATES
Extract Date & Time Features
Weekend Flag
Days Between Dates
Finding the Dates a Number of Days Before & After
STATISTICS & FORMULAS
Common Statistics
Absolute Values
Round, Ceiling & Floor
Modulus of Values in a DataFrame
Creating a Column of Random Numbers
Search Snippets Collections Code Builder Login
  • Search Snippets
  • Snippet Collections
  • Code Builder
  • Login

Snippets Tagged "smote"

Balancing Imbalanced Datasets with SMOTE: A Python Example Using imbalanced-learn
Python
Data Preprocessing

Python | Imbalanced-learn | Smote

Greg He
1
By using Datasnips, you agree to our privacy policy including our cookie policy