One-Hot Encoder

Expand a categorical CSV column into binary indicator columns.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Paste the CSV or drop a file.
2
Step 2
Enter the categorical column name.
3
Step 3
Press Process and copy the expanded CSV.

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?
Enter the column name and press Process.
Does it drop the first category?
No. All categories get a column.
What are the new columns called?
The original name, an underscore and the category, such as product_Widget.
One-hot or label encoding?
One-hot for nominal categories with no order; label encoding for ordered categories or tree models.

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 YouTube
  • Mean, 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.