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

SQL Snippets

Getting the Last Record Using Rank Function - T-SQL Example
SQL
Querying

T-SQL

Greg He
2
Getting the Date for the Previous Saturday with T-SQL
SQL
Querying

T-SQL

Greg He
2
Remove Leading Zeros from a Field with T-SQL
SQL
Querying

T-SQL | Data Cleaning

Greg He
2
median
SQL
Querying

changjulian17
2
left join LATERAL
SQL
Querying

changjulian17
2
Join on Multiple Columns in SQL Query
SQL
Querying

Joins | Multiple

analyseup
1
EXISTS
SQL
Querying

changjulian17
1
SQL RANK
SQL
Querying

changjulian17
1
SQL window function
SQL
Querying

changjulian17
1
SQL window function II: percent growth
SQL
Querying

changjulian17
1
SQL creating a view
SQL
Querying

changjulian17
1
SQL generate_series, dayofweek(DOW), weekday, functions
SQL
Querying

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