[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-25 Thread mortada
Github user mortada commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r80405104
  
--- Diff: python/pyspark/sql/functions.py ---
@@ -411,7 +415,7 @@ def monotonically_increasing_id():
 
 The generated ID is guaranteed to be monotonically increasing and 
unique, but not consecutive.
 The current implementation puts the partition ID in the upper 31 bits, 
and the record number
-within each partition in the lower 33 bits. The assumption is that the 
data frame has
+within each partition in the lower 33 bits. The assumption is that the 
DataFrame has
--- End diff --

@HyukjinKwon great idea, will update 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-19 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r79344483
  
--- Diff: python/pyspark/sql/functions.py ---
@@ -411,7 +415,7 @@ def monotonically_increasing_id():
 
 The generated ID is guaranteed to be monotonically increasing and 
unique, but not consecutive.
 The current implementation puts the partition ID in the upper 31 bits, 
and the record number
-within each partition in the lower 33 bits. The assumption is that the 
data frame has
+within each partition in the lower 33 bits. The assumption is that the 
DataFrame has
--- End diff --

It'd be nicer if we use `:class:`DataFrame` instead of the plain string 
`DateFrame` if you would like to change this. This makes this as a link to the 
`DataFrame` class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread mortada
Github user mortada commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78480019
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -1393,6 +1420,7 @@ def withColumnRenamed(self, existing, new):
 :param existing: string, name of the existing column to rename.
 :param col: string, new name of the column.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.withColumnRenamed('age', 'age2').collect()
 [Row(age2=2, name=u'Alice'), Row(age2=5, name=u'Bob')]
--- End diff --

@HyukjinKwon thank you, I'll update the PR 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479721
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -1393,6 +1420,7 @@ def withColumnRenamed(self, existing, new):
 :param existing: string, name of the existing column to rename.
 :param col: string, new name of the column.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.withColumnRenamed('age', 'age2').collect()
 [Row(age2=2, name=u'Alice'), Row(age2=5, name=u'Bob')]
--- End diff --

`[Row(name=u'Alice', age2=2), Row(name=u'Bob', age2=5)]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479675
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -1378,6 +1404,7 @@ def withColumn(self, colName, col):
 :param colName: string, name of the new column.
 :param col: a :class:`Column` expression for the new column.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.withColumn('age2', df.age + 2).collect()
 [Row(age=2, name=u'Alice', age2=4), Row(age=5, name=u'Bob', 
age2=7)]
--- End diff --

`[Row(name=u'Alice', age=2, age2=4), Row(name=u'Bob', age=5, age2=7)]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479591
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -106,6 +106,7 @@ def toJSON(self, use_unicode=True):
 
 Each row is turned into a JSON document as one element in the 
returned RDD.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.toJSON().first()
 u'{"age":2,"name":"Alice"}'
--- End diff --

`u'{"name":"Alice","age":2}'`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479631
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -329,6 +339,7 @@ def toLocalIterator(self):
 Returns an iterator that contains all of the rows in this 
:class:`DataFrame`.
 The iterator will consume as much memory as the largest partition 
in this DataFrame.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> list(df.toLocalIterator())
 [Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
--- End diff --

`[Row(name=u'Alice', age=2), Row(name=u'Bob', age=5)]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479542
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -1444,6 +1474,7 @@ def toDF(self, *cols):
 
 :param cols: list of new column names (string)
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.toDF('f1', 'f2').collect()
 [Row(f1=2, f2=u'Alice'), Row(f1=5, f2=u'Bob')]
--- End diff --

`[Row(f1=u'Alice', f2=2), Row(f1=u'Bob', f2=5)]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-12 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15053#discussion_r78479505
  
--- Diff: python/pyspark/sql/dataframe.py ---
@@ -354,6 +366,7 @@ def limit(self, num):
 def take(self, num):
 """Returns the first ``num`` rows as a :class:`list` of 
:class:`Row`.
 
+>>> df = spark.createDataFrame([('Alice', 2), ('Bob', 5)], 
['name', 'age'])
 >>> df.take(2)
 [Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
--- End diff --

`[Row(name=u'Alice', age=2), Row(name=u'Bob', age=5)]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15053: [Doc] improve python API docstrings

2016-09-11 Thread mortada
GitHub user mortada opened a pull request:

https://github.com/apache/spark/pull/15053

[Doc] improve python API docstrings

## What changes were proposed in this pull request?

a lot of the python API functions show example usage that is incomplete. 
The docstring shows output without having the input DataFrame defined. It can 
be quite confusing trying to understand the example. This PR fixes the 
docstring.

## How was this patch tested?

docs changes only




You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mortada/spark python_docstring

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/15053.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #15053


commit 52240bcf8df42dd454e874ce7640d7040c5cdad9
Author: Mortada Mehyar 
Date:   2016-09-11T20:28:54Z

[Doc] improve python API docstrings




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org