How it works...
In this recipe, we identified the variable data types of a publicly available dataset by inspecting the data type in which the variables are cast and the distinct values they take. First, we used pandas read_csv() to load the data from a CSV file into a dataframe. Next, we used pandas dtypes to display the data types in which the variables are cast, which can be float for continuous variables, int for integers, and object for strings. We observed that the continuous variable fare was cast as float, the discrete variable sibsp was cast as int, and the categorical variable embarked was cast as an object. Finally, we identified the distinct values of a variable with the unique() method from pandas. We used unique() together with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access