Skip to content

Commit e8a2004

Browse files
committed
Switch example so that there is not confusion about the single and double quotes due to capitalization
1 parent eb28496 commit e8a2004

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

docs/source/user-guide/basics.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ source file as described in the :ref:`Introduction <guide>`, the Pokemon data se
2525

2626
.. ipython:: python
2727
28-
from datafusion import SessionContext, col, functions as F
28+
from datafusion import SessionContext, col, lit, functions as f
2929
3030
ctx = SessionContext()
3131
32-
df = ctx.read_csv("pokemon.csv")
32+
df = ctx.read_parquet("yellow_tripdata_2021-01.parquet")
3333
3434
df = df.select(
35-
'"Name"',
36-
(col('"Attack"') - col('"Defense"')).alias("delta"),
37-
col('"Speed"')
35+
"trip_distance",
36+
col("total_amount").alias("total"),
37+
(f.round(lit(100.0) * col("tip_amount") / col("total_amount"), lit(1))).alias("tip_percent"),
3838
)
3939
4040
df.show()
@@ -65,7 +65,7 @@ The second statement group creates a :code:`DataFrame`,
6565
.. code-block:: python
6666
6767
# Create a DataFrame from a file
68-
df = ctx.read_csv("pokemon.csv")
68+
df = ctx.read_parquet("yellow_tripdata_2021-01.parquet")
6969
7070
A DataFrame refers to a (logical) set of rows that share the same column names, similar to a `Pandas DataFrame <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html>`_.
7171
DataFrames are typically created by calling a method on :py:class:`~datafusion.context.SessionContext`, such as :code:`read_csv`, and can then be modified by
@@ -75,14 +75,17 @@ and :py:func:`~datafusion.dataframe.DataFrame.limit` to build up a query definit
7575
Expressions
7676
-----------
7777

78-
The third statement uses :code:`Expressions` to build up a query definition.
78+
The third statement uses :code:`Expressions` to build up a query definition. You can find
79+
explanations for what the functions below do in the user documentation for
80+
:py:func:`~datafusion.col`, :py:func:`~datafusion.lit`, :py:func:`~datafusion.functions.round`,
81+
and :py:func:`~datafusion.expr.Expr.alias`.
7982

8083
.. code-block:: python
8184
8285
df = df.select(
83-
'"Name"',
84-
(col('"Attack"') - col('"Defense"')).alias("delta"),
85-
col('"Speed"')
86+
"trip_distance",
87+
col("total_amount").alias("total"),
88+
(f.round(lit(100.0) * col("tip_amount") / col("total_amount"), lit(1))).alias("tip_percent"),
8689
)
8790
8891
Finally the :py:func:`~datafusion.dataframe.DataFrame.show` method converts the logical plan

0 commit comments

Comments
 (0)