Skip to content

Instantly share code, notes, and snippets.

@vallantin
Created August 15, 2018 19:54
Show Gist options
  • Save vallantin/210afa74ca477fc68700497630d671c2 to your computer and use it in GitHub Desktop.
Save vallantin/210afa74ca477fc68700497630d671c2 to your computer and use it in GitHub Desktop.
Find the indexes of the elements that are divisible by 5 on a series
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 7\n",
"1 3\n",
"2 8\n",
"3 5\n",
"4 8\n",
"5 8\n",
"6 4\n",
"dtype: int64\n"
]
},
{
"data": {
"text/plain": [
"array([[3]])"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"serie = pd.Series(np.random.randint(1,10,7))\n",
"print(serie)\n",
"\n",
"np.argwhere(serie % 5==0)"
]
}
],
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment