I am trying to find duplicate values of a dataframe column and its count in descending order.
Able to achieve with below code
dfNew = df.pivot_table(index=['Title'],aggfunc='size').sort_values(ascending=False)
However, when I print the dfNew
, the results are coming as expected but the title of columns is blank. How to ensure results display under the Title and count columns
<table>
<tbody>
<tr>
<td>Australia Beach</td>
<td>2</td>
</tr>
<tr>
<td>Canada Beach</td>
<td>5</td>
</tr>
</tbody>
</table>