{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T21:53:49.133235Z", "start_time": "2018-12-24T21:53:49.017526Z" } }, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Standard data science libraries\n", "import pandas as pd\n", "import numpy as np\n", "\n", "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "import cufflinks\n", "cufflinks.go_offline()\n", "\n", "# Options for pandas\n", "pd.options.display.max_columns = 20\n", "\n", "# Display all cell outputs\n", "from IPython.core.interactiveshell import InteractiveShell\n", "InteractiveShell.ast_node_interactivity = 'all'\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T22:08:31.320898Z", "start_time": "2018-12-24T22:08:31.316561Z" } }, "outputs": [], "source": [ "pmi = pd.DataFrame({'Fund': ['Vanguard Institutional', 'Fidelity 500', 'American Funds'],\n", " 'Value': ['$1,273,473,951', '$933,104,732', '$127,202,400']})\n", "\n", "agi = pd.DataFrame({'Fund': ['Vanguard Institutional', 'Fidelity 500'],\n", " 'Value': ['$978,581,386', '$835,683,676']})" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T22:09:36.535833Z", "start_time": "2018-12-24T22:09:36.444719Z" } }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": true }, "data": [ { "marker": { "color": "rgba(226, 74, 51, 0.6)", "line": { "color": "rgba(226, 74, 51, 1.0)", "width": 1 } }, "name": "Value", "orientation": "v", "text": "", "type": "bar", "uid": "5e16de5d-c909-4e29-80cd-f97e5632d955", "x": [ "Vanguard Institutional", "Fidelity 500", "American Funds" ], "y": [ "$1,273,473,951", "$933,104,732", "$127,202,400" ] } ], "layout": { "margin": { "l": 120 }, "title": "Mutual Fund Holdings in Philip Morris", "xaxis": { "title": "Fund", "titlefont": { "size": 16 } }, "yaxis": { "tickformat": "$,", "title": "Value of Holdings", "titlefont": { "size": 16 } } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pmi.iplot(kind='bar', x='Fund', y='Value',\n", " layout = dict( margin=dict(l=120), title = 'Mutual Fund Holdings in Philip Morris',\n", " xaxis = dict(title='Fund', titlefont=dict(size=16)),\n", " yaxis = dict(title='Value of Holdings', \n", " titlefont=dict(size=16),\n", " tickformat=f'$,')))" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T22:25:50.061706Z", "start_time": "2018-12-24T22:25:49.972014Z" } }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": true }, "data": [ { "marker": { "color": "rgba(226, 74, 51, 0.6)", "line": { "color": "rgba(226, 74, 51, 1.0)", "width": 1 } }, "name": "Value", "orientation": "v", "text": "", "type": "bar", "uid": "48730da9-7630-4025-8ab0-a835cb6ddb94", "x": [ "Vanguard Institutional", "Fidelity 500" ], "y": [ "$978,581,386", "$835,683,676" ] } ], "layout": { "margin": { "l": 120 }, "title": "Mutual Fund Holdings in Altria Group", "xaxis": { "title": "Fund", "titlefont": { "size": 16 } }, "yaxis": { "tickformat": "$,", "title": "Value of Holdings", "titlefont": { "size": 16 } } } }, "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "agi.iplot(kind='bar', x='Fund', y='Value',\n", " layout = dict( margin=dict(l=120), title = 'Mutual Fund Holdings in Altria Group',\n", " xaxis = dict(title='Fund', titlefont=dict(size=16)),\n", " yaxis = dict(title='Value of Holdings', \n", " titlefont=dict(size=16),\n", " tickformat=f'$,')))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "hide_input": false, "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" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }