Skip to content

Commit 7fe5779

Browse files
committed
Add a simple example to the introduction page to demonstrate loading a dataframe from a csv file and displaying the contents
1 parent 54e5e0d commit 7fe5779

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
147 KB
Loading

docs/source/user-guide/introduction.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,43 @@ You can verify the installation by running:
3939
import datafusion
4040
datafusion.__version__
4141
42+
In this documentation we will also show some examples for how DataFusion integrates
43+
with Jupyter notebooks. To install and start a Jupyter labs session use
4244

45+
.. code-block:: shell
46+
47+
pip install jupyterlab
48+
jupyter lab
49+
50+
To demonstrate working with DataFusion, we need a data source. Later in the tutorial we will show
51+
options for data sources. For our first example, we demonstrate using a Pokemon dataset that you
52+
can download
53+
`here <https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv>`_.
54+
55+
.. code-block:: shell
56+
57+
curl -O https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv
58+
59+
With that file in place you can use the following python example to view the DataFrame in
60+
DataFusion.
61+
62+
.. ipython:: python
63+
64+
from datafusion import SessionContext
65+
66+
ctx = SessionContext()
67+
68+
df = ctx.read_csv("pokemon.csv")
69+
70+
df.show()
71+
72+
If you are working in a Jupyter notebook, you can also use the following to give you a table
73+
display that may be easier to read.
74+
75+
.. code-block:: shell
76+
77+
display(df)
4378
79+
.. image:: ../../_static/images/jupyter_lab_df_view.png
80+
:width: 800
81+
:alt: Rendered table showing Pokemon DataFrame

0 commit comments

Comments
 (0)