I want to get a count of the rows in dataframe:
count1 = df[(df['col1'] == xxx) & (df['col2'] == yyy)].count() But it still return Series. How can I get the actual count as int?
Unclear what you're expecting here df.count() returns a series or df showing you the row or column count, why would you expect a simple scalar value returned?
If you wanted just the row cound then perform len(count) or count.shape[0]
example:
In [173]: df = pd.DataFrame({'a':[0,2,2,3,5], 'b':[0,1,1,3,5], 'c':np.random.randn(5)}) df Out[173]: a b c 0 0 0 -1.192011 1 2 1 0.290372 2 2 1 -0.092076 3 3 3 0.821918 4 5 5 0.551033 In [180]: count1 = df[(df['a'] == 2) & (df['b']==1)] len(count1) Out[180]: 2
['col1']at the end to get an int. Or anything else that effectively reduces the series to a single value.