gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
python dataframe how to check column types
- User
python dataframe how to check column types
- Assistant
To check the column types of a DataFrame in Python, you can use the dtypes attribute of the DataFrame. Here's an example:
import pandas as pd # Create a DataFrame data = { 'Name': ['John', 'Emily', 'Michael'], 'Age': [25, 30, 35], 'Height': [175.5, 160.0, 185.0], 'HasPets': [False, True, True] } df = pd.DataFrame(data) # Check column types print(df.dtypes)Output:
Name object Age int64 Height float64 HasPets bool dtype: objectIn the output, the column types are listed next to their respective column names. For example, "Name" is of type "object" (string), "Age" is of type "int64", "Height" is of type "float64", and "HasPets" is of type "bool".
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.