Newer
Older
"1304 Łuck\n",
"893 Šibenik\n",
"0 NaN\n",
"[1545 rows x 1 columns]"
"execution_count": 23,
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.sort_values(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It seems like there's something weird going on with 'Békéscsaba', it doesn't sort right. What is wrong?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's extract the datum:"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 Békéscsaba \n",
"Name: 1248, dtype: object"
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.iloc[1248]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"More specifically the column '0':"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' Békéscsaba '"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.iloc[1248][0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Seems there's a space in front of the 'B'. That's why it sorts wrong."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}