Checking data types of each Column in a Data Frame.
- If you want to check the data type of each column, because whenever you have been given a data, you want to really check what is the structure of the data; that means, which variable has which data type?
- In, that case you can use dtypes, because that returns a series with the data type of each column and the syntax would be you use dtypes along with the Data Frame name.
- So, Data Frame.dtypes will give you a series with the data type of each column
Here is the syntax.
Syntax = DataFrame.dtypes
Count of unique data types
- So, now we have an overall idea about what are the data types that we are going to work with using the cars_data.
- There is also an option where you can get the count of unique data types available in your Data Frame.
- So, in that case get_dtype_counts, returns the counts of unique data types in the data frame.
Selecting data based on data types
- So, now we also have an overall idea about the count of unique data types that we are going to handle with.
- So, now, we know about how to get the data type of each variables. So, there might be cases where you want to perform the operations only on a numerical data type.
- Similarly, there can be cases where you are going to work with only categorical data type.
Here is the syntax.
Syntax = pandas.DataFrame.select.dtypes()
0 Comments:
Post a Comment