Data Cleaner
Clean a table one step at a time: missing values, duplicate rows, stray spaces, text in number columns, filters, sorting and rescaling. Every step goes into a recipe you can edit, save and use again, and into a pandas script that gives the same table.
Drop a CSV file here
Columns split by commas, tabs, semicolons, pipes or spaces. The delimiter, decimal commas and the header row are found for you.
Step 2: Clean
Suggested for this table
Recipe
No steps yet. Each step you add is listed here in order, with the rows it leaves. Click a step to see the table at that point, switch it off to see the table without it, or edit, move and remove it; the table is worked out again from the file each time.
Table
Step 3: Take it with you
The cleaned table, the recipe to apply it to another file here, and the script to run it anywhere.
data_cleaned.csv
To clean another file the same way, load it here: the recipe stays and is applied to it.
How to clean a table and keep the recipe
Load a file, add the steps it needs, and take away the cleaned CSV, the recipe and a pandas script that repeats it, without opening Python, R or a spreadsheet.
Load your file
Drag a .csv, .tsv, .txt or .dat file onto the drop zone, or press Choose file. The delimiter, a decimal comma and the header row are found for you; change them above the table if the guess is wrong. Load a sample gives you a small file with gaps, a repeated row, stray spaces and a note in a number column to practise on.
Add steps
Pick an action, choose the columns and press Add step; the line under the button tells you what it will do before you add it. Suggested for this table offers one-click fixes for what the page spots, such as repeated rows or text with spaces around it. Click a column name in the table to use it in the step.
Work with the recipe
Each step is listed with the rows it leaves. Click a step to see the table at that point; switch it off, edit it, move it or remove it, and the table is worked out again from the file. Undo and Redo (Ctrl+Z, Ctrl+Shift+Z) step through your changes.
Take it with you
Download the cleaned CSV, Save the recipe to open it here again on another file, or copy the Python script: it reads the file, applies the same steps with pandas, prints the rows after each one and writes the same CSV.
What each step does
Rows
Drop rows with missing values removes rows with an empty cell in the columns you choose (or in any). Remove duplicate rows keeps the first of each set of rows that repeat, comparing the columns you choose; the number 1 and the text "1" are different values. Keep rows where tests one column: more than and the other comparisons only let numbers through, contains ignores case. Sort rows is stable: numbers come first, then text ignoring case, and missing values stay last in either direction.
Values
Fill missing values with a value, the column mean or median (of its numbers), or the value above. Replace values swaps whole cells, such as n.d. for a missing value, or text inside text cells, such as kg for nothing. Trim spaces removes spaces, tabs and line breaks at the ends of text (and can shrink runs inside); text left empty becomes missing. Convert text to numbers turns text such as " 12 " into 12.
Numbers
Round numbers to decimal places or significant figures, as the number is written: 2.675 becomes 2.68, where most software gives 2.67 because the stored value is 2.67499…. Ties go away from zero, or to the even digit if you choose. Transform numbers: log10 and ln (zero and negative values become missing), absolute value, multiply, add, min–max to 0 to 1, and z-scores.
Columns and the script
Rename a column and Remove columns change the table's shape; later steps use the new names. The Python script reads the file with the same settings, runs each step as a commented pandas block and writes the CSV the page downloads, byte for byte: every rule here is written into it.
12, -0.5 or 1e-7; an empty cell is missing; anything else, including NA, true and dates, stays text, so a column can hold numbers and text side by side. Whole numbers of 253 and above stay text, so long IDs keep their digits. Mark text such as NA as missing with Replace values.How the numbers are worked out
Rescaling follows the standard feature-scaling definitions, over the numbers in the column; text and missing cells are left out and left alone.
Min–max rescaling maps a column onto the range [0, 1]:
A z-score centres a column on 0 with unit standard deviation:
where x is a cell value, {x}_{\min }/{x}_{\max } the column extremes, μ the column mean, σ the population standard deviation (dividing by N, as scikit-learn’s StandardScaler does; pandas’ std() divides by N-1), and N the count of numbers. A constant column maps to 0.
The same result in pandas. Sums are exact (the algorithm of Python’s math.fsum), so a mean does not depend on the order numbers are added in. Logarithms are correctly rounded, since Math.log and C’s log differ in the last bit for about one value in a hundred. Numbers are written as JavaScript writes them (298, 1e-7), and text is compared by code point rather than by the browser’s language. The script does each of these the same way, and the page’s tests run it with pandas to check the two agree cell for cell.
References & documentation
- Pedregosa, F., et al. (2011). Scikit-learn: Machine learning in Python. JMLR, 12, 2825–2830. Docs: StandardScaler · Preprocessing guide.
- McKinney, W. (2010). Data structures for statistical computing in Python. Proceedings of the 9th Python in Science Conference, 56–61. pandas documentation.
- Shewchuk, J. R. (1997). Adaptive precision floating-point arithmetic and fast robust geometric predicates. Discrete & Computational Geometry, 18, 305–363 (the exact sums).
- Heckert, N. A., Filliben, J. J., Croarkin, C., et al. (2002). NIST/SEMATECH e-Handbook of Statistical Methods. itl.nist.gov/div898/handbook.
Frequently asked questions
Is my file uploaded to a server?
Does the Python script give exactly the same result?
How do I apply the same cleaning to another file?
INPUT in the Python script. A step that names a column the new file does not have is marked and skipped.Why is "NA" not treated as missing?
NA, n.d. or -999 is never removed by accident. Use Replace values with an empty replacement to mark it as missing.How is the z-score calculated?
Why does the preview show only 200 rows?
Runs entirely in your browser, no data leaves your device.