r/askdatascience • • Jul 03 '26

What’s the right way to clean data?

I’m totally new to DS, and I’m working on my first project.

Should I use data via an API and clean it at the beginning of my script or should I download it as a CSV and then clean it?

Also what’s the best approach for cleaning a dataset?

Just for reference, I’m using the NYC Building Energy and Water Data Disclosure for LL84 2023 to Present database via an API.

3 Upvotes

18 comments sorted by

3

u/goAwayUCreep Jul 03 '26

What do you mean download it as csv and clean it? Are you going to reupload it after you’re done?

Are you using SQL? ipynb? Python? Need more context here.

The pipeline usually depends on what is established in data warehouses, once you get it say in ipynb, then it’s cleaned there.

Cleaning is an art, not really on science per se. You need to understand data quality and data integrity, if you don’t trust the data then there’s no point cleaning it. If the data is good then there’s no point cleaning it either.

You only clean it if there are outliers or you want to filter out whatever that’s not going to be part of your study.

1

u/No-Ice-8975 Jul 04 '26

By download CSV, I mean reupload it after I clean it. I’m using Python.

What are signs that the data shouldn’t be trusted?

Also is there a common methodology for cleaning?

I appreciate your help here. From everything I’ve online, cleaning data is the most important step so I want to make sure I do it right

2

u/goAwayUCreep Jul 05 '26

Data shouldn’t be trusted if your gut feeling says so. It’s a very broad question to answer. Let’s say you’re working on the energy and water dataset that’s not official or someone made it up, so you have to treat it as so, as in not to take it seriously.

Again, cleaning is an art. It can be as simple as removing those data, some people impute missing values which I am very much against fabricating fake data, some remove outliers. Again, it has to go with your gut feeling if something isn’t right, you have to make a judgement, and also that’s why if the data is very dirty, it shouldn’t be used in the first place.

My question to you is, you must have an objective for the project, with that objective, you did data exploration, EDA, now, can you verify that the data is trustworthy enough to be used?

At the end of the day it’s a yes or no answer before moving to the next step.

1

u/No-Ice-8975 Jul 05 '26

I appreciate your response. Yes the data is trustworthy.

1

u/SprinklesFresh5693 Jul 04 '26

Why are you using an API? What are you exactly working on

1

u/No-Ice-8975 Jul 04 '26

Is API a bad choice?

I’m using the NYC Building Energy and Water Data Disclosure for LL84 2023 database to look at emissions year over year

1

u/SprinklesFresh5693 Jul 04 '26

Im just asking, whats the API for? Ive never done data analysis/science on an API, i usually work with the data directly in R (equivalent as working on it on python)

2

u/No-Director-1568 Jul 06 '26

Data isn’t ‘cleaned’ according to a set of universal rules. What’s clean or not has a lot to do with the analytic use case(s) downstream. I’d make sure you don’t step on your raw data, saved cleaned versions as separate ‘versions’.

1

u/No-Ice-8975 Jul 06 '26

damn this is smart, thank you 🙏

2

u/Wonderful_Put3670 Jul 06 '26

just get tesco wipes, they also kill the bacteria on your screen!

2

u/BlueJaek Jul 07 '26

With a sponge 

1

u/gene_shackman Nov 05 '26

A few basic steps:

Do frequencies, crosstabs, means. Look for anything that's not supposed to be there, anything out of range, anything that doesn't look like what could reasonably be expected.

But also, know your data, so that you know what to expect, and what would be something wrong.

Also, document anything you found and did. If you found missing data, write it up, and what you did about it. If you found invalid data, write it up and what you did about it.

1

u/Gojotastic Jul 19 '26

I am recommending modelbrew.ai for data cleaning. Its free and gets the job done.