Flat 10% & upto 40% off + 10% Cashback + Free additional Courses. Hurry up

Scrubbing Data


As we know the obtained data has inconsistencies, errors, weird characters, missing values or different problems. In this situation, you have to scrub, or clean the data before to use this data. So for scrubbing the data some techniques are used which are as follows:-

  • Filter lines
  • Extract certain columns or words
  • Replace values
  • Handle missing values
  • Convert data from one format to another

 Looking for top jobs in Data Science ? This blog post gives you all the information you need!

Filtering Lines

The first scrubbing operation is to filter lines. It means that from the input data every line will be calculated to determine whether it may be passed on as output.

  • Based on location

Based on their location is the simplest way to filter lines. It is useful when you want to inspect, say, the top 5 lines of a file, or when you want extract a particular row from the output of another command-line tool.

  • Based on pattern

If you want to extract or remove lines based on their contents then use grep which is canonical command-line tool for filtering lines. We can print every line that matches a certain pattern or regular expression.

  • Based on randomness

When you’re in the process of formulating your data pipeline and have a bulk of data, then debugging your pipeline can be cumbersome. In that case, sampling from the data might be useful. The core reason of the command-line tool sample is to get a subset of the data by outputting only a particular percentage of the input on a line-by-line basis.

Read these Top Trending Data Science Interview Q’s  blog now that helps you grab high-paying jobs!

Replacing and Deleting Values

Command-line tool tr, which stands for translate that can be used to replace the individual characters. For example, spaces can be replaced by comma as follows:

$ echo 'hello world!' | tr ' ' ','


If more than one character is need to be replaced, then

$ echo 'hello world!' | tr ' !' ',?'


tr can also be used to delete individual characters by specifying the -d option:

$ echo 'hello world!' | tr -d -c '[a-z]'



Working with CSV

The command-line tools which are used to scrub plain text, like as grep and tr, cannot always be applied to CSV. The reason is that these command-line tools have no notion of headers, bodies, and columns. In order to leverage ordinary command-line tools for CSV: body, header, and cols.

The first command-line tool is body. With this command line tool, you can apply any command-line tool to the body of a CSV file i.e., everything excluding the header.

For example:

$ echo -e "value\n7\n2\n5" | body sort -n





The second command-line tool header is used to permit us to operate the header of a CSV file. The third command-line tool is cols, which is similar to header and body. It permits you to apply a certain command to only a subset of the columns.

Learn more about Data Science in this insightful blog now!

"0 Responses on Scrubbing Data"

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

Sales Offer

  • To avail this offer, enroll before 20th April 2018.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer

Sign Up or Login to view the Free Scrubbing Data.