341 lines
7.3 KiB
Plaintext
341 lines
7.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import plotly"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'4.1.1'"
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"plotly.__version__"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = pd.read_csv('data/nz_weather.csv')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div>\n",
|
|
"<style scoped>\n",
|
|
" .dataframe tbody tr th:only-of-type {\n",
|
|
" vertical-align: middle;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe tbody tr th {\n",
|
|
" vertical-align: top;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe thead th {\n",
|
|
" text-align: right;\n",
|
|
" }\n",
|
|
"</style>\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>DATE</th>\n",
|
|
" <th>Auckland</th>\n",
|
|
" <th>Christchurch</th>\n",
|
|
" <th>Dunedin</th>\n",
|
|
" <th>Hamilton</th>\n",
|
|
" <th>Wellington</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>2000-01</td>\n",
|
|
" <td>115.4</td>\n",
|
|
" <td>47.2</td>\n",
|
|
" <td>174.8</td>\n",
|
|
" <td>96.2</td>\n",
|
|
" <td>91.8</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>2000-02</td>\n",
|
|
" <td>8.4</td>\n",
|
|
" <td>25.2</td>\n",
|
|
" <td>41</td>\n",
|
|
" <td>8.2</td>\n",
|
|
" <td>35.2</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>2000-03</td>\n",
|
|
" <td>57.2</td>\n",
|
|
" <td>60.8</td>\n",
|
|
" <td>74.2</td>\n",
|
|
" <td>33.8</td>\n",
|
|
" <td>53.4</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>3</th>\n",
|
|
" <td>2000-04</td>\n",
|
|
" <td>106.8</td>\n",
|
|
" <td>58.2</td>\n",
|
|
" <td>50</td>\n",
|
|
" <td>129.6</td>\n",
|
|
" <td>109.8</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>4</th>\n",
|
|
" <td>2000-05</td>\n",
|
|
" <td>128.2</td>\n",
|
|
" <td>62.0</td>\n",
|
|
" <td>'-</td>\n",
|
|
" <td>98.2</td>\n",
|
|
" <td>78.2</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" DATE Auckland Christchurch Dunedin Hamilton Wellington\n",
|
|
"0 2000-01 115.4 47.2 174.8 96.2 91.8\n",
|
|
"1 2000-02 8.4 25.2 41 8.2 35.2\n",
|
|
"2 2000-03 57.2 60.8 74.2 33.8 53.4\n",
|
|
"3 2000-04 106.8 58.2 50 129.6 109.8\n",
|
|
"4 2000-05 128.2 62.0 '- 98.2 78.2"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"data.head()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import plotly.graph_objects as go"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"line1 = go.Scatter(x=data['DATE'], y=data['Auckland'], name='Auckland')\n",
|
|
"line2 = go.Scatter(x=data['DATE'], y=data['Wellington'], name='Wellington')\n",
|
|
"fig = go.Figure([line1, line2])\n",
|
|
"fig.update_layout(\n",
|
|
" title = \"New Zealand Weather\",\n",
|
|
" xaxis_title = \"Date\",\n",
|
|
" yaxis_title = \"Weather\"\n",
|
|
")\n",
|
|
"fig.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%% md\n"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Bar Chart"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"data_2010 = data[(data['DATE'] >= '2010-01') & (data['DATE'] < '2011-01')]\n",
|
|
"data_2010"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"bar1 = go.Bar(x = data_2010['DATE'], y = data_2010['Auckland'], \n",
|
|
" text = data_2010['Auckland'], textposition='outside')\n",
|
|
"fig = go.Figure(bar1)\n",
|
|
"fig.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"bar1 = go.Bar(x = data_2010['DATE'], y = data_2010['Auckland'], \n",
|
|
" text = data_2010['Auckland'], textposition='outside', name='Auckland')\n",
|
|
"bar2 = go.Bar(x = data_2010['DATE'], y = data_2010['Wellington'], \n",
|
|
" text = data_2010['Wellington'], textposition='outside', name='Wellington')\n",
|
|
"fig = go.Figure([bar1, bar2])\n",
|
|
"fig.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%% md\n"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Histogram"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"hist = go.Histogram(x = data['Auckland'])\n",
|
|
"fig = go.Figure(hist)\n",
|
|
"fig.update_layout(bargap=0.1)\n",
|
|
"fig.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"hist = go.Histogram(x = data['Auckland'], xbins={'size': 10})\n",
|
|
"fig = go.Figure(hist)\n",
|
|
"fig.update_layout(bargap=0.1)\n",
|
|
"fig.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pycharm": {
|
|
"name": "#%%\n"
|
|
}
|
|
},
|
|
"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.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
} |