Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/sql-programming-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ DataFrames provide a domain-specific language for structured data manipulation i

Here we include some basic examples of structured data processing using DataFrames:


<div class="codetabs">
<div data-lang="scala" markdown="1">
{% highlight scala %}
Expand Down Expand Up @@ -242,6 +241,12 @@ df.groupBy("age").count().show();
</div>

<div data-lang="python" markdown="1">
In Python it's possible to access a DataFrame's columns either by attribute
(`df.age`) or by indexing (`df['age']`). While the former is convenient for
interactive data exploration, users are highly encouraged to use the
latter form, which is future proof and won't break with column names that
are also attributes on the DataFrame class.

{% highlight python %}
from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
Expand Down Expand Up @@ -270,14 +275,14 @@ df.select("name").show()
## Justin

# Select everybody, but increment the age by 1
df.select(df.name, df.age + 1).show()
df.select(df['name'], df['age'] + 1).show()
## name (age + 1)
## Michael null
## Andy 31
## Justin 20

# Select people older than 21
df.filter(df.age > 21).show()
df.filter(df['age'] > 21).show()
## age name
## 30 Andy

Expand Down