One-Hot Encoder
Expand a categorical CSV column into binary indicator columns.
About this tool
Name a categorical column and get one new 0/1 column for each distinct value, named column_value. Machine-learning models need numbers, and one-hot columns avoid implying an order between categories.
How to use
How it works
The distinct values are sorted alphabetically and each gets a new column holding 1 where the row has that value and 0 otherwise. The original column stays in place, and the new columns are added at the right. No category is dropped, so the columns are linearly dependent; drop one for linear models.
Worked example
Encode product
- Input
- product: Widget, Gadget, Widget, Gadget, Widget, Gadget, Widget
- Output
- categories: Gadget, Widget new columns: product_Gadget, product_Widget row 1: Widget -> product_Gadget 0, product_Widget 1
- Walkthrough
- Every row has exactly one 1 across the two new columns.
Limitations
- The original column is kept, so remove it before modeling.
- No option to drop the first category or to set a maximum number of categories.
- High-cardinality columns create very many columns.
- Unseen categories in new data are not handled because there is no reusable encoder.
Questions
How do I one-hot encode a column in a CSV?
Does it drop the first category?
What are the new columns called?
One-hot or label encoding?
Features
- 0/1 indicator columns
- Alphabetical categories
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
What Is A RESTful API?
Traversy Media
APIs are how most data tools receive payloads.
Watch on YouTubeMean, Variance and Standard Deviation
StatQuest with Josh Starmer
Spread metrics when analyzing pasted datasets.
Watch on YouTube
- Data Index
Math is Fun
Stats explainers when summarizing columns.
- Fetch API
MDN
How browsers pull remote data into local tools.