OSGeoLive-Notebooks/Pandas/Finally.ipynb

126 lines
2.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Finally, some more notes"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"try:\n",
" import seaborn\n",
"except ImportError:\n",
" pass"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## About the dtypes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- Missing values (NaN) cast integer or boolean arrays to floats\n",
"- The object dtype is the fallback\n",
"- Some custom dtypes (Categorical, tz datetime (upcoming))\n",
"- Some custom objects, eg Timestamp"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"dft = pd.DataFrame(dict(A = np.random.rand(3),\n",
" B = 1,\n",
" C = 'foo',\n",
" D = pd.Timestamp('20010102'),\n",
" E = pd.Series([1.0]*3).astype('float32'),\n",
" F = False,\n",
" G = pd.Series([1]*3,dtype='int8'),\n",
" H = pd.Series(['a', 'b', 'a'], dtype='category')))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"A float64\n",
"B int64\n",
"C object\n",
"D datetime64[ns]\n",
"E float32\n",
"F bool\n",
"G int8\n",
"H category\n",
"dtype: object"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dft.dtypes"
]
},
{
"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.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}