Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get columns based on dtype pandas

>>df.select_dtypes(include='object').columns

Index(['C', 'D'], dtype='object')
Comment

get columns by type pandas

In [2]: df = pd.DataFrame({'NAME': list('abcdef'),
    'On_Time': [True, False] * 3,
    'On_Budget': [False, True] * 3})

In [3]: df.select_dtypes(include=['bool'])
Out[3]:
  On_Budget On_Time
0     False    True
1      True   False
2     False    True
3      True   False
4     False    True
5      True   False

In [4]: mylist = list(df.select_dtypes(include=['bool']).columns)

In [5]: mylist
Out[5]: ['On_Budget', 'On_Time']
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter start maximized 
Python :: how to get the angle of mouse from the center formulae 
Python :: pyspark session 
Python :: E: Unable to locate package python3-pip docker file 
Python :: py for line in file 
Python :: simplify fractions python 
Python :: string array to float array python 
Python :: LookupError: unknown encoding: idna python 
Python :: last element in dictionary python 
Python :: selenium get current url 
Python :: How to develop a TCP echo server, in Python? 
Python :: how to trim mp4 with moviepy 
Python :: python remove empty folders 
Python :: how to add input box in tkinter 
Python :: get all classes from css file using python 
Python :: how to play a mp3 file in python 
Python :: increase contrast cv2 
Python :: python parse args 
Python :: python print to terminal with color 
Python :: require http method django view 
Python :: python plot cut off when saving 
Python :: close selenium webdriver python 
Python :: print(np.round(df.isnull().sum() / len(df), 2)) 
Python :: jupyter no output cell 
Python :: python get the elements between quotes in string 
Python :: python detect keypress 
Python :: what is nea in python 
Python :: talos get best model 
Python :: how to take a screenshot using python 
Python :: plotly title font size 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =