how could I retrieve the value count of a particular data type ?
Tried several ways with index label, end up in key error.
To get the result, ended up creating a new dataframe with the datatype name as column name, there should be some other efficient way.
df =pd.DataFrame([[‘Bob’, 20, 2],[‘Alice’, 19, 3],[‘Joshua’, 22, 1]], columns = [‘Name’, ‘Age’, ‘Marks’])
print(df.dtypes.value_counts())
strIndex = strdtypes.keys().tolist()
strIndex = [str(d) for d in strIndex]
df1 =pd.DataFrame({‘datatype’:strIndex, ‘valuecount’:strdtypes})
count =df1[df1[‘datatype’]==’int64′][‘valuecount’]
print (“count int64 “, count)`
Ramanathan Alamelu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.