[PYTHON] How to find a specific type (str, float etc) column in a DataFrame column

How to find a specific type (str, float etc) column in a DataFrame column

Age City
0 21 Tokyo

When there is a data frame called.

When returning as a bool value

python



df.dtypes == object

>>
Age False
City True
dtype: bool

When returning a column

python



df.loc[:, df.dtypes == object]

>>
    Age    City
0   21    Tokyo

When storing column names in a list

python



mylist = list(df.select_dtypes(include = ['object']).columns)

mylist 

>>
['City']


Recommended Posts

How to find a specific type (str, float etc) column in a DataFrame column
How to get a specific column name and index name in pandas DataFrame
How to count numbers in a specific range
How to display DataFrame as a table in Markdown
A handy function to add a column anywhere in a Pandas DataFrame
How to display a specified column of files in Linux (awk)
How to find the memory address of a Pandas dataframe value
How to split and save a DataFrame
How to get a stacktrace in python
How to sort by specifying a column in the Python Numpy array.
How to stop a program in python until a specific date and time
How to clear tuples in a list (Python)
How to embed a variable in a python string
How to create a JSON file in Python
How to implement a gradient picker in Houdini
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
Convert exponential notation float to str in Python
How to write a named tuple document in 2020
How to use loc / iloc / ix to get by specifying a column in CASTable
How to handle datetime type in python sqlite3
How to read a file in a different directory
How to Mock a Public function in Pytest
How to find the first element that matches your criteria in a Python list
How to specify a schema in Django's database settings
How to apply markers only to specific data in matplotlib
How to convert Python # type for Python super beginners: str
How to write a list / dictionary type of Python3
A memorandum on how to use keras.preprocessing.image in Keras
How to execute a command using subprocess in Python
How to reference static files in a Django project
Whole type conversion for each dataframe column in python
[Linux] How to put your IP in a variable
How to find out if there is an arbitrary value in "somewhere" of pandas DataFrame
How to find the cumulative sum / sum for each group using DataFrame in Spark [Python version]
How to find the optimal number of clusters in k-means
How to slice a block multiple array from a multiple array in Python
How to import NoteBook as a module in Jupyter (IPython)
How to output a document in pdf format with Sphinx
A story about how to specify a relative path in python.
How to import a file anywhere you like in Python
How to temporarily implement a progress bar in a scripting language
How to define multiple variables in a python for statement
Put the lists together in pandas to make a DataFrame
A note on how to load a virtual environment in PyCharm
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to generate a query using the IN operator in Django
How to check if a value exists in an enum
How to extract other than a specific index with Numpy
How to get the last (last) value in a list in Python
How to convert Python # type for Python super beginners: int, float
How to get a list of built-in exceptions in python
How to find the scaling factor of a biorthogonal wavelet
How to import NoteBook as a module in Jupyter (IPython)
Simultaneously input specific data to a specific sheet in many excels
How to get a quadratic array of squares in a spiral!
How to call a function
How to hack a terminal
How to find Mahalanobis distance