Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created August 31, 2016 07:16
Show Gist options
  • Save lxneng/3de3a5e982f37c049ed44eed2630e48f to your computer and use it in GitHub Desktop.
Save lxneng/3de3a5e982f37c049ed44eed2630e48f to your computer and use it in GitHub Desktop.
identify-duplicated-row
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>city</th>\n",
" <th>score</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>shanghai</td>\n",
" <td>100099</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" city score\n",
"1 shanghai 100099"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"df = pd.DataFrame([{'city': 'shanghai', 'score': 1000000},\n",
" {'city': 'shanghai', 'score': 100099},\n",
" {'city': 'guangzhou', 'score': 10000},\n",
" {'city': 'beijing', 'score': 100987}])\n",
"df[df.duplicated('city')]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment