使用Datapane制作数据报告#

Using Datapane to build shareable reports

image.png

datapane/datapane

pip install datapane
Collecting datapane
  Downloading datapane-0.8.1-py3-none-any.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 75 kB/s eta 0:00:015
?25hCollecting altair<5.0.0,>=4.0.0
  Downloading altair-4.1.0-py3-none-any.whl (727 kB)
     |████████████████████████████████| 727 kB 27 kB/s eta 0:00:01
?25hCollecting furl<3.0.0,>=2.1.0
  Downloading furl-2.1.0-py2.py3-none-any.whl (20 kB)
Requirement already satisfied: matplotlib<4.0.0,>=3.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (3.1.3)
Collecting importlib_resources<4.0.0,>=3.0.0
  Downloading importlib_resources-3.0.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: jinja2<3.0.0,>=2.11.1 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (2.11.1)
Requirement already satisfied: toolz<0.11.0,>=0.10.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (0.10.0)
Requirement already satisfied: click<8.0.0,>=7.0.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (7.0)
Requirement already satisfied: tabulate<0.9.0,>=0.8.7 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (0.8.7)
Collecting click-spinner<0.2.0,>=0.1.8
  Downloading click_spinner-0.1.10-py2.py3-none-any.whl (4.0 kB)
Collecting pyarrow<0.18.0,>=0.17.0
  Downloading pyarrow-0.17.1-cp37-cp37m-macosx_10_9_intel.whl (42.0 MB)
     |████████████████████████████████| 42.0 MB 51 kB/s eta 0:00:013
?25hCollecting dacite<2.0.0,>=1.2.0
  Downloading dacite-1.5.1-py3-none-any.whl (12 kB)
Collecting stringcase<2.0.0,>=1.2.0
  Downloading stringcase-1.2.0.tar.gz (3.0 kB)
Collecting colorlog<5.0.0,>=4.1.0
  Downloading colorlog-4.4.0-py2.py3-none-any.whl (14 kB)
Collecting plotly<5.0.0,>=4.8.1
  Downloading plotly-4.11.0-py2.py3-none-any.whl (13.1 MB)
     |████████████████████████████████| 13.1 MB 47 kB/s eta 0:00:01
?25hRequirement already satisfied: ruamel.yaml<0.17.0,>=0.16.5 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (0.16.10)
Requirement already satisfied: numpy<2.0.0,>=1.18.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (1.18.1)
Requirement already satisfied: jsonschema<4.0.0,>=3.2.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (3.2.0)
Requirement already satisfied: requests<3.0.0,>=2.20.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (2.24.0)
Collecting bokeh<3.0.0,>=2.0.0
  Downloading bokeh-2.2.3.tar.gz (8.8 MB)
     |████████████████████████████████| 8.8 MB 17 kB/s eta 0:00:018
?25hRequirement already satisfied: pandas<2.0.0,>=1.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (1.0.1)
Collecting validators<0.19.0,>=0.18.0
  Downloading validators-0.18.1-py3-none-any.whl (19 kB)
Collecting packaging<21.0,>=20.3
  Downloading packaging-20.4-py2.py3-none-any.whl (37 kB)
Collecting requests-toolbelt<0.10.0,>=0.9.1
  Downloading requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 45 kB/s eta 0:00:01
?25hCollecting folium<0.12.0,>=0.11.0
  Downloading folium-0.11.0-py2.py3-none-any.whl (93 kB)
     |████████████████████████████████| 93 kB 74 kB/s eta 0:00:01
?25hCollecting nbconvert<6.1.0,>=6.0.0
  Downloading nbconvert-6.0.7-py3-none-any.whl (552 kB)
     |████████████████████████████████| 552 kB 43 kB/s eta 0:00:013
?25hCollecting flit-core<2.4.0,>=2.3.0
  Downloading flit_core-2.3.0-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 49 kB/s eta 0:00:01
?25hRequirement already satisfied: PyYAML<6.0.0,>=5.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from datapane) (5.3)
Collecting lxml<5.0.0,>=4.5.2
  Downloading lxml-4.6.1-cp37-cp37m-macosx_10_9_x86_64.whl (4.5 MB)
     |████████████████████████████████| 4.5 MB 16 kB/s eta 0:00:01
?25hCollecting munch<3.0.0,>=2.5.0
  Downloading munch-2.5.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: entrypoints in /opt/anaconda3/lib/python3.7/site-packages (from altair<5.0.0,>=4.0.0->datapane) (0.3)
Collecting orderedmultidict>=1.0.1
  Downloading orderedmultidict-1.0.1-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: six>=1.8.0 in /opt/anaconda3/lib/python3.7/site-packages (from furl<3.0.0,>=2.1.0->datapane) (1.14.0)
Requirement already satisfied: cycler>=0.10 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib<4.0.0,>=3.1.0->datapane) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib<4.0.0,>=3.1.0->datapane) (1.1.0)
Requirement already satisfied: python-dateutil>=2.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib<4.0.0,>=3.1.0->datapane) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib<4.0.0,>=3.1.0->datapane) (2.4.6)
Requirement already satisfied: zipp>=0.4; python_version < "3.8" in /opt/anaconda3/lib/python3.7/site-packages (from importlib_resources<4.0.0,>=3.0.0->datapane) (2.2.0)
Requirement already satisfied: MarkupSafe>=0.23 in /opt/anaconda3/lib/python3.7/site-packages (from jinja2<3.0.0,>=2.11.1->datapane) (1.1.1)
Collecting retrying>=1.3.3
  Using cached retrying-1.3.3.tar.gz (10 kB)
Requirement already satisfied: ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.9" in /opt/anaconda3/lib/python3.7/site-packages (from ruamel.yaml<0.17.0,>=0.16.5->datapane) (0.2.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /opt/anaconda3/lib/python3.7/site-packages (from jsonschema<4.0.0,>=3.2.0->datapane) (0.15.7)
Requirement already satisfied: attrs>=17.4.0 in /opt/anaconda3/lib/python3.7/site-packages (from jsonschema<4.0.0,>=3.2.0->datapane) (19.3.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from jsonschema<4.0.0,>=3.2.0->datapane) (46.0.0.post20200309)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /opt/anaconda3/lib/python3.7/site-packages (from jsonschema<4.0.0,>=3.2.0->datapane) (1.7.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests<3.0.0,>=2.20.0->datapane) (2019.11.28)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests<3.0.0,>=2.20.0->datapane) (1.25.8)
Requirement already satisfied: idna<3,>=2.5 in /opt/anaconda3/lib/python3.7/site-packages (from requests<3.0.0,>=2.20.0->datapane) (2.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests<3.0.0,>=2.20.0->datapane) (3.0.4)
Collecting pillow>=7.1.0
  Downloading Pillow-8.0.0-cp37-cp37m-macosx_10_10_x86_64.whl (2.2 MB)
     |████████████████████████████████| 2.2 MB 26 kB/s eta 0:00:01
?25hRequirement already satisfied: tornado>=5.1 in /opt/anaconda3/lib/python3.7/site-packages (from bokeh<3.0.0,>=2.0.0->datapane) (6.0.3)
Requirement already satisfied: typing_extensions>=3.7.4 in /opt/anaconda3/lib/python3.7/site-packages (from bokeh<3.0.0,>=2.0.0->datapane) (3.7.4.2)
Requirement already satisfied: pytz>=2017.2 in /opt/anaconda3/lib/python3.7/site-packages (from pandas<2.0.0,>=1.0.1->datapane) (2019.3)
Requirement already satisfied: decorator>=3.4.0 in /opt/anaconda3/lib/python3.7/site-packages (from validators<0.19.0,>=0.18.0->datapane) (4.4.1)
Collecting branca>=0.3.0
  Downloading branca-0.4.1-py3-none-any.whl (24 kB)
Collecting nbclient<0.6.0,>=0.5.0
  Downloading nbclient-0.5.1-py3-none-any.whl (65 kB)
     |████████████████████████████████| 65 kB 19 kB/s eta 0:00:01
?25hRequirement already satisfied: pandocfilters>=1.4.1 in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (1.4.2)
Requirement already satisfied: mistune<2,>=0.8.1 in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (0.8.4)
Requirement already satisfied: jupyter-core in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (4.6.1)
Collecting jupyterlab-pygments
  Downloading jupyterlab_pygments-0.1.2-py2.py3-none-any.whl (4.6 kB)
Requirement already satisfied: bleach in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (3.1.0)
Requirement already satisfied: testpath in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (0.4.4)
Requirement already satisfied: traitlets>=4.2 in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (4.3.3)
Requirement already satisfied: pygments>=2.4.1 in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (2.5.2)
Requirement already satisfied: defusedxml in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (0.6.0)
Requirement already satisfied: nbformat>=4.4 in /opt/anaconda3/lib/python3.7/site-packages (from nbconvert<6.1.0,>=6.0.0->datapane) (5.0.4)
Collecting pytoml
  Downloading pytoml-0.1.21-py2.py3-none-any.whl (8.5 kB)
Collecting async-generator
  Downloading async_generator-1.10-py3-none-any.whl (18 kB)
Collecting nest-asyncio
  Downloading nest_asyncio-1.4.1-py3-none-any.whl (5.2 kB)
Collecting jupyter-client>=6.1.5
  Downloading jupyter_client-6.1.7-py3-none-any.whl (108 kB)
     |████████████████████████████████| 108 kB 21 kB/s eta 0:00:01
?25hRequirement already satisfied: webencodings in /opt/anaconda3/lib/python3.7/site-packages (from bleach->nbconvert<6.1.0,>=6.0.0->datapane) (0.5.1)
Requirement already satisfied: ipython-genutils in /opt/anaconda3/lib/python3.7/site-packages (from traitlets>=4.2->nbconvert<6.1.0,>=6.0.0->datapane) (0.2.0)
Requirement already satisfied: pyzmq>=13 in /opt/anaconda3/lib/python3.7/site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert<6.1.0,>=6.0.0->datapane) (18.1.1)
Building wheels for collected packages: stringcase, bokeh, retrying
  Building wheel for stringcase (setup.py) ... ?25ldone
?25h  Created wheel for stringcase: filename=stringcase-1.2.0-py3-none-any.whl size=3576 sha256=08e1013b473f0dc75a5bbc1983375e2e08f9276bc0603783f889a940193710f9
  Stored in directory: /Users/datalab/Library/Caches/pip/wheels/86/ab/a3/a8fa7e0a07e80f547e03468c03827f8257f7339327986faed1
  Building wheel for bokeh (setup.py) ... ?25ldone
?25h  Created wheel for bokeh: filename=bokeh-2.2.3-py3-none-any.whl size=9296309 sha256=1ac68c5ef988ad5effacf1d280c614b9e134c63c08dcee3364fed555443c9436
  Stored in directory: /Users/datalab/Library/Caches/pip/wheels/0c/6a/ac/5de7ec1983d76fa1243106008b70df211dceb5ed643ad15699
  Building wheel for retrying (setup.py) ... ?25ldone
?25h  Created wheel for retrying: filename=retrying-1.3.3-py3-none-any.whl size=11430 sha256=a0ca1b4655bf4181dcee100929261a5e39118513b42636d02352e828ad76564a
  Stored in directory: /Users/datalab/Library/Caches/pip/wheels/f9/8d/8d/f6af3f7f9eea3553bc2fe6d53e4b287dad18b06a861ac56ddf
Successfully built stringcase bokeh retrying
ERROR: spyder 4.0.1 requires pyqt5<5.13; python_version >= "3", which is not installed.
ERROR: spyder 4.0.1 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
ERROR: pytest-astropy 0.8.0 requires pytest-cov>=2.0, which is not installed.
ERROR: pytest-astropy 0.8.0 requires pytest-filter-subpackage>=0.1, which is not installed.
ERROR: datapane 0.8.1 has requirement ruamel.yaml<0.17.0,>=0.16.5, but you'll have ruamel-yaml 0.15.87 which is incompatible.
Installing collected packages: altair, orderedmultidict, furl, importlib-resources, click-spinner, pyarrow, dacite, stringcase, colorlog, retrying, plotly, pillow, packaging, bokeh, validators, requests-toolbelt, branca, folium, async-generator, nest-asyncio, jupyter-client, nbclient, jupyterlab-pygments, nbconvert, pytoml, flit-core, lxml, munch, datapane
  Attempting uninstall: pyarrow
    Found existing installation: pyarrow 0.12.1
    Uninstalling pyarrow-0.12.1:
      Successfully uninstalled pyarrow-0.12.1
  Attempting uninstall: pillow
    Found existing installation: Pillow 7.0.0
    Uninstalling Pillow-7.0.0:
      Successfully uninstalled Pillow-7.0.0
  Attempting uninstall: packaging
    Found existing installation: packaging 20.1
    Uninstalling packaging-20.1:
      Successfully uninstalled packaging-20.1
  Attempting uninstall: bokeh
    Found existing installation: bokeh 1.4.0
    Uninstalling bokeh-1.4.0:
      Successfully uninstalled bokeh-1.4.0
  Attempting uninstall: jupyter-client
    Found existing installation: jupyter-client 5.3.4
    Uninstalling jupyter-client-5.3.4:
      Successfully uninstalled jupyter-client-5.3.4
  Attempting uninstall: nbconvert
    Found existing installation: nbconvert 5.6.1
    Uninstalling nbconvert-5.6.1:
      Successfully uninstalled nbconvert-5.6.1
  Attempting uninstall: lxml
    Found existing installation: lxml 4.5.0
    Uninstalling lxml-4.5.0:
      Successfully uninstalled lxml-4.5.0
Successfully installed altair-4.1.0 async-generator-1.10 bokeh-2.2.3 branca-0.4.1 click-spinner-0.1.10 colorlog-4.4.0 dacite-1.5.1 datapane-0.8.1 flit-core-2.3.0 folium-0.11.0 furl-2.1.0 importlib-resources-3.0.0 jupyter-client-6.1.7 jupyterlab-pygments-0.1.2 lxml-4.6.1 munch-2.5.0 nbclient-0.5.1 nbconvert-6.0.7 nest-asyncio-1.4.1 orderedmultidict-1.0.1 packaging-20.4 pillow-8.0.0 plotly-4.11.0 pyarrow-0.17.1 pytoml-0.1.21 requests-toolbelt-0.9.1 retrying-1.3.3 stringcase-1.2.0 validators-0.18.1
Note: you may need to restart the kernel to use updated packages.
import pandas as pd
import altair as alt
import datapane as dp
df = pd.read_csv('https://query1.finance.yahoo.com/v7/finance/download/GOOG?period2=1585222905&interval=1mo&events=history')

chart = alt.Chart(df).encode(
    x='Date:T',
    y='Open'
).mark_line().interactive()

r = dp.Report(dp.Table(df), dp.Plot(chart))
r.save(path='report.html', open=True)