Additional cleaning functions and data conversion
Let's examine additional parameters of the functions that can help when importing data. Sometimes the data can be littered or have a wrong format—for example, instead of numeric, there may appear text data or it can be missing completely.
You can control the format of the incoming data with the help of templates that are used in the Case
function. For example, if you need only numeric data to be imported, then the template will look like this: x_?NumericQ
.
Note
All information about data types used in Mathematica can be found at http://reference.wolfram.com/language/tutorial/PuttingConstraintsOnPatterns.html.
Let's take a wider range of data for the analysis on unemployment in a country (country, date, and unemployment rate):
When you import data, it is important to check the format of the input data—for example, the number 2.3
can be identified as the string "2.3", and as a result, we are no longer able to work...