You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "panbingkun (via GitHub)" <gi...@apache.org> on 2023/11/20 03:09:14 UTC

[PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

panbingkun opened a new pull request, #43897:
URL: https://github.com/apache/spark/pull/43897

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403831809


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures

Review Comment:
   This isn't really useful here as it includes one class alone. Should probably just remove them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403831456


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating Through `read.format(...).load(...)`
+---------------------------------------------
+
+Creating a PySpark :class:`DataFrame` by reading existing **json** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **csv** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").
+    ...     load("python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **parquet** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("parquet").load("python/test_support/sql/people.parquet")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+Creating a PySpark :class:`DataFrame` by reading existing **orc** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("parquet").load("python/test_support/sql/people.orc")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading data from other databases using **JDBC**
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+

Review Comment:
   I think we should really have a self-contained example, e.g. https://sparkbyexamples.com/pyspark/pyspark-read-and-write-mysql-database-table/. We could have a separate page for this, and link it here. Could be done separately in another PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403832135


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures

Review Comment:
   Or, include the methods being used here. e.g., `` :meth:`SparkSession.createDataFrame ``, `` :meth:`DataFrameReader.load` ``, etc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1398626446


##########
python/docs/source/user_guide/10min.rst:
##########
@@ -0,0 +1,188 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+=====================
+10 minutes to PySpark

Review Comment:
   We actually already have 10 minutes (https://spark.apache.org/docs/latest/api/python/getting_started/quickstart_df.html). Let's rename it better like DataFrame creation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1410106899


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")

Review Comment:
   I haven't found any relevant documents yet, or we can add one later and reference it in this place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1400324847


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:

Review Comment:
   Pyspark -> PySpark



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the DataFrame.

Review Comment:
   DataFrame -> :class:\`DataFrame\`



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the DataFrame.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    df
+
+DataFrame[_1: string, _2: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    df
+
+DataFrame[_1: string, _2: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    df
+
+DataFrame[age: bigint, name: string]
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    from pyspark.sql import Row
+    Person = Row('name', 'age')
+    df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    df
+
+DataFrame[name: string, age: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    import pandas as pd
+    df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    df
+
+DataFrame[0: bigint, 1: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    import numpy as np
+    import pandas as pd
+    df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]), columns=['a', 'b']))
+    df
+
+DataFrame[a: bigint, b: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from an :class:`pyspark.RDD`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python

Review Comment:
   > I think we'd better not mention RDD since it is not supported on connect
   
   +1, or at least we should add a note.



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.

Review Comment:
   Maybe do we want to mention  :class:\`numpy.ndarray\`  here as well? e.g.
   
   ```suggestion
   A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing a list of lists, tuples, dictionaries, :class:`Row`, a pandas :class:`pandas.DataFrame`, a NumPy :class:\`numpy.ndarray\` and an :class:`pyspark.RDD`.
   ```



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation

Review Comment:
   Maybe shall we capitalizing the first word of the title/sub-title for consistency with other documents?
   
   e.g. DataFrame Creation / Basic Data Structures  ...



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation

Review Comment:
   Maybe shall we capitalizing the first word of the title/sub-title for consistency with other documents?
   
   e.g. DataFrame Creation / Basic Data Structures  ...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "nchammas (via GitHub)" <gi...@apache.org>.
nchammas commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1426075998


##########
python/docs/source/user_guide/sql/creating_dataframes.rst:
##########
@@ -0,0 +1,223 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+===================
+Creating DataFrames
+===================
+
+.. currentmodule:: pyspark.sql
+
+PySpark allows you to create :class:`DataFrame`\s in several ways. Let's explore these methods with simple examples.
+
+Creating a :class:`DataFrame` from Lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+    :emphasize-lines: 5
+
+    >>> # when the schema is not provided, the resulting DataFrame has _1 and _2 as the schema
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` with a Specified Schema
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Define a schema and use it to create a :class:`DataFrame`. A schema describes the column names and types.
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import StructType, StructField, StringType, IntegerType
+    >>> schema = StructType([
+    ...     StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)
+    ... ])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+Use DDL-formatted string schema to create a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from Dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dictionaries with keys as column names can also be used.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a :class:`DataFrame` from :class:`Row`\s
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Use the :class:`Row` type to define rows of a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from a :class:`pandas.DataFrame` or a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Reading Data from Files
+-----------------------
+
+Example with **JSON**
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **CSV**
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").load(
+    ...     "python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **PARQUET**
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> # Write a Parquet file to the temporary directory, and read it back
+    >>> import tempfile
+    >>> with tempfile.TemporaryDirectory() as d:
+    ...     # Overwrite the path with a new Parquet file
+    ...     spark.createDataFrame(
+    ...         [{"age": None, "name": "Michael"}, {"age": 30, "name": "Andy"}]
+    ...     ).write.mode("overwrite").format("parquet").save(d)
+    ...     # Read the Parquet file as a DataFrame
+    ...     df = spark.read.format("parquet").load(d)
+    ...     df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |  30|   Andy|
+    |NULL|Michael|
+    +----+-------+
+
+Example with **ORC**
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> # Write a Orc file to the temporary directory, and read it back
+    >>> import tempfile
+    >>> with tempfile.TemporaryDirectory() as d:
+    ...     # Overwrite the path with a new Orc file
+    ...     spark.createDataFrame(
+    ...         [{"age": None, "name": "Michael"}, {"age": 30, "name": "Andy"}]
+    ...     ).write.mode("overwrite").format("orc").save(d)
+    ...     # Read the Orc file as a DataFrame

Review Comment:
   ```suggestion
       ...     # Read the ORC file as a DataFrame
   ```



##########
python/docs/source/user_guide/sql/creating_dataframes.rst:
##########
@@ -0,0 +1,223 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+===================
+Creating DataFrames
+===================
+
+.. currentmodule:: pyspark.sql
+
+PySpark allows you to create :class:`DataFrame`\s in several ways. Let's explore these methods with simple examples.
+
+Creating a :class:`DataFrame` from Lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+    :emphasize-lines: 5
+
+    >>> # when the schema is not provided, the resulting DataFrame has _1 and _2 as the schema
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` with a Specified Schema
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Define a schema and use it to create a :class:`DataFrame`. A schema describes the column names and types.
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import StructType, StructField, StringType, IntegerType
+    >>> schema = StructType([
+    ...     StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)
+    ... ])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+Use DDL-formatted string schema to create a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from Dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dictionaries with keys as column names can also be used.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a :class:`DataFrame` from :class:`Row`\s
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Use the :class:`Row` type to define rows of a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from a :class:`pandas.DataFrame` or a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Reading Data from Files
+-----------------------
+
+Example with **JSON**
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **CSV**
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").load(
+    ...     "python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **PARQUET**
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> # Write a Parquet file to the temporary directory, and read it back
+    >>> import tempfile
+    >>> with tempfile.TemporaryDirectory() as d:
+    ...     # Overwrite the path with a new Parquet file
+    ...     spark.createDataFrame(
+    ...         [{"age": None, "name": "Michael"}, {"age": 30, "name": "Andy"}]
+    ...     ).write.mode("overwrite").format("parquet").save(d)
+    ...     # Read the Parquet file as a DataFrame
+    ...     df = spark.read.format("parquet").load(d)
+    ...     df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |  30|   Andy|
+    |NULL|Michael|
+    +----+-------+
+
+Example with **ORC**
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> # Write a Orc file to the temporary directory, and read it back

Review Comment:
   Nit: It's [Apache ORC](https://orc.apache.org) (upper case).
   
   ```suggestion
       >>> # Write an ORC file to a temporary directory and read it back.
   ```



##########
python/docs/source/user_guide/sql/creating_dataframes.rst:
##########
@@ -0,0 +1,223 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+===================
+Creating DataFrames
+===================
+
+.. currentmodule:: pyspark.sql
+
+PySpark allows you to create :class:`DataFrame`\s in several ways. Let's explore these methods with simple examples.
+
+Creating a :class:`DataFrame` from Lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+    :emphasize-lines: 5
+
+    >>> # when the schema is not provided, the resulting DataFrame has _1 and _2 as the schema
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` with a Specified Schema
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Define a schema and use it to create a :class:`DataFrame`. A schema describes the column names and types.
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import StructType, StructField, StringType, IntegerType
+    >>> schema = StructType([
+    ...     StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)
+    ... ])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+Use DDL-formatted string schema to create a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from Dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dictionaries with keys as column names can also be used.
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a :class:`DataFrame` from :class:`Row`\s
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Use the :class:`Row` type to define rows of a :class:`DataFrame`.
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a :class:`DataFrame` from a :class:`pandas.DataFrame` or a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Reading Data from Files
+-----------------------
+
+Example with **JSON**
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **CSV**
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").load(
+    ...     "python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Example with **PARQUET**
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> # Write a Parquet file to the temporary directory, and read it back

Review Comment:
   Nit: No need for a comma here.
   
   ```suggestion
       >>> # Write a Parquet file to a temporary directory and read it back.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1400159072


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the DataFrame.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    df
+
+DataFrame[_1: string, _2: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    df
+
+DataFrame[_1: string, _2: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    df
+
+DataFrame[age: bigint, name: string]
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    from pyspark.sql import Row
+    Person = Row('name', 'age')
+    df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    df
+
+DataFrame[name: string, age: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    import pandas as pd
+    df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    df
+
+DataFrame[0: bigint, 1: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    import numpy as np
+    import pandas as pd
+    df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]), columns=['a', 'b']))
+    df
+
+DataFrame[a: bigint, b: bigint]
+
+
+Creating a PySpark :class:`DataFrame` from an :class:`pyspark.RDD`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python

Review Comment:
   I think we'd better not mention RDD since it is not supported on connect



##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the DataFrame.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists

Review Comment:
   shall we also add examples for `schema` in `createDataFrame`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1398627880


##########
python/docs/source/user_guide/10min.rst:
##########
@@ -0,0 +1,188 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+=====================
+10 minutes to PySpark

Review Comment:
   Okay



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403831650


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating Through `read.format(...).load(...)`
+---------------------------------------------
+
+Creating a PySpark :class:`DataFrame` by reading existing **json** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **csv** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").
+    ...     load("python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **parquet** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("parquet").load("python/test_support/sql/people.parquet")

Review Comment:
   I think we should make the example self-contained with including `spark.range(10).write("parquet")` with properly adding comments.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403829936


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating Through `read.format(...).load(...)`
+---------------------------------------------
+
+Creating a PySpark :class:`DataFrame` by reading existing **json** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **csv** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").
+    ...     load("python/test_support/sql/people.csv")

Review Comment:
   This won't work because of the indentation.
   ```suggestion
       >>> df = spark.read.format("csv").option("header", "true").load(
       ...     "python/test_support/sql/people.csv")
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403830598


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating Through `read.format(...).load(...)`

Review Comment:
   Preposition starts with a lower case.
   
   ```suggestion
   Creating through `read.format(...).load(...)`
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "allisonwang-db (via GitHub)" <gi...@apache.org>.
allisonwang-db commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1409849131


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation

Review Comment:
   ```suggestion
   Creating DataFrames in PySpark
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples

Review Comment:
   Do we need to show this example? Which one is better? From lists or tuples? We should provide opinionated ways to create DataFrames.



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.

Review Comment:
   Personally, I think we don't need this section. We can directly dive into different ways to create data frames and add some explanations there.



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+

Review Comment:
   ```suggestion
   PySpark allows you to create DataFrames in several ways. Let's explore these methods with simple examples.
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists

Review Comment:
   ```suggestion
   Creating a :class:`DataFrame` from Lists
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])

Review Comment:
   ```suggestion
   schema = StructType([
       StructField("name", StringType(), True),
       StructField("age", IntegerType(), True)
   ])
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified

Review Comment:
   Let's combine this with the previous section



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+

Review Comment:
   ```suggestion
   Define a schema and use it to create a DataFrame. A schema describes the column names and types.
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified

Review Comment:
   ```suggestion
   Creating a :class:`DataFrame` with a Specified Schema
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|

Review Comment:
   Maybe we should highlight that when the schema is not provided, the resulting data frame has `_1` and `_2` as the schema  (this differs from pandas for example)



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+

Review Comment:
   
   ```suggestion
   Use the Row type to define rows of a DataFrame.
   
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`

Review Comment:
   ```suggestion
   Creating a :class:`DataFrame` from :class:`Row`s
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`

Review Comment:
   ```suggestion
   Creating a :class:`DataFrame` from a :class:`pandas.DataFrame` or a :class:`numpy.ndarray`
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating through `read.format(...).load(...)`
+---------------------------------------------
+
+Creating a PySpark :class:`DataFrame` by reading existing **json** format file data

Review Comment:
   Here we can combine all sections to show examples:
   ```
   - Example with JSON 
   <code block>
   - Example with CSV
   <code block>
   - Example with Parquet
   <code block>
   - Example with JDBC
   <code block>
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`

Review Comment:
   We can combine this with the previous section.



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating through `read.format(...).load(...)`

Review Comment:
   Reading Data from Files



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+

Review Comment:
   ```suggestion
   Dictionaries with keys as column names can also be used.
   
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *

Review Comment:
   Let's not use `import *`
   ```
   from pyspark.sql.types import StructType, StructField, StringType, IntegerType
   ```



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")

Review Comment:
   "name string, age int" Just curious, do we have any documentation on this DDL string format? How to translate a pyspark type into this DDL string format?



##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit DDL-formatted string schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema = "name string, age int")
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries

Review Comment:
   ```suggestion
   Creating a :class:`DataFrame` from Dictionaries
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1831003144

   cc @allanf-db FYI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1855078032

   > Will the code in this guide be tested by our Python doc tests, by the way?
   
   No, but I have manually tested it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1402872980


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    df

Review Comment:
   Okay



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1820718220

   Done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1825064564

   Looks pretty good otherwise.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403879127


##########
python/docs/source/user_guide/index.rst:
##########
@@ -26,6 +26,7 @@ PySpark specific user guides are available here:
    :maxdepth: 2
 
    python_packaging
+   dataframe_creation

Review Comment:
   @HyukjinKwon Should we do similar operations? Move it under `sql/index`?
   
   <img width="916" alt="image" src="https://github.com/apache/spark/assets/15246973/c38ee451-836f-4d53-85a9-d586ca7309b8">
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-2016641997

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1400175341


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic data structures
+---------------------
+
+Pyspark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`
+and an :class:`pyspark.RDD` consisting of such a list.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the DataFrame.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists

Review Comment:
   Okay



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1404041842


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of dictionaries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
+    >>> df.show()
+    +---+-----+
+    |age| name|
+    +---+-----+
+    |  1|Alice|
+    +---+-----+
+
+
+Creating a PySpark :class:`DataFrame` from a list of :class:`Row`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql import Row
+    >>> Person = Row('name', 'age')
+    >>> df = spark.createDataFrame([Person("Alice", 1), Person("Bob", 5)])
+    >>> df.show()
+    +-----+---+
+    | name|age|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`pandas.DataFrame`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame([[1, 2]]))
+    >>> df.show()
+    +---+---+
+    |  0|  1|
+    +---+---+
+    |  1|  2|
+    +---+---+
+
+
+Creating a PySpark :class:`DataFrame` from a :class:`numpy.ndarray`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> import numpy as np
+    >>> import pandas as pd
+    >>> df = spark.createDataFrame(pd.DataFrame(data=np.array([[1, 2], [3, 4]]),
+    ...     columns=['a', 'b']))
+    >>> df.show()
+    +---+---+
+    |  a|  b|
+    +---+---+
+    |  1|  2|
+    |  3|  4|
+    +---+---+
+
+
+Creating Through `read.format(...).load(...)`
+---------------------------------------------
+
+Creating a PySpark :class:`DataFrame` by reading existing **json** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("json").load("python/test_support/sql/people.json")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **csv** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("csv").option("header", "true").
+    ...     load("python/test_support/sql/people.csv")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading existing **parquet** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("parquet").load("python/test_support/sql/people.parquet")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+Creating a PySpark :class:`DataFrame` by reading existing **orc** format file data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.read.format("parquet").load("python/test_support/sql/people.orc")
+    >>> df.show()
+    +----+-------+
+    | age|   name|
+    +----+-------+
+    |NULL|Michael|
+    |  30|   Andy|
+    |  19| Justin|
+    +----+-------+
+
+
+Creating a PySpark :class:`DataFrame` by reading data from other databases using **JDBC**
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+

Review Comment:
   Okay, Let me temporarily remove this section from the document. 
   I have already created a new jira, and when I start this jira https://issues.apache.org/jira/browse/SPARK-46088, 
   I will add this section back and link it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "allanf-db (via GitHub)" <gi...@apache.org>.
allanf-db commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1409861283


##########
python/docs/source/user_guide/sql/index.rst:
##########
@@ -16,13 +16,14 @@
     under the License.
 
 
-=========
-Spark SQL
-=========
+=================
+DataFrame and SQL

Review Comment:
   I think we should be consistent with the main PySpark doc page terminology now that we are changing this:
   https://spark.apache.org/docs/latest/api/python/index.html
   
   On the page, we say "Spark SQL and DataFrames"
   I suggest we do the same here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "nchammas (via GitHub)" <gi...@apache.org>.
nchammas commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1854991274

   Will the code in this guide be tested by our Python doc tests, by the way?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #43897: [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation
URL: https://github.com/apache/spark/pull/43897


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1402869871


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    df

Review Comment:
   what about using `df.show()` in the examples instead to show the data?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1403830830


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,233 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Basic Data Structures
+---------------------
+
+PySpark provides an important class for handling data:
+
+1. :class:`DataFrame`: a distributed collection of data grouped into named columns.
+
+Creating Through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` with the explicit schema specified
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> from pyspark.sql.types import *
+    >>> schema = StructType([StructField("name", StringType(), True),
+    ...     StructField("age", IntegerType(), True)])
+    >>> df = spark.createDataFrame([('Alice', 1), ('Bob', 5)], schema)

Review Comment:
   We should probably show an example with a string DDL schema schema



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1820363945

   Cc @itholic @allisonwang-db @zhengruifeng mind reviewing this please when you find some time?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1400364744


##########
python/docs/source/user_guide/dataframe_creation.rst:
##########
@@ -0,0 +1,179 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame creation

Review Comment:
   Okay



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1818163072

   After:
   <img width="1183" alt="image" src="https://github.com/apache/spark/assets/15246973/8d930743-76f8-4d72-963c-35f3afe6406e">
   <img width="1389" alt="image" src="https://github.com/apache/spark/assets/15246973/ad54dfc1-19d3-4359-8d77-b6eb24682157">
   <img width="1095" alt="image" src="https://github.com/apache/spark/assets/15246973/bb0e49df-34b4-4ccf-80b8-46cb97b6744c">
   <img width="1102" alt="image" src="https://github.com/apache/spark/assets/15246973/ee79e187-e518-4527-b8e2-a87b9940f78a">
   <img width="1109" alt="image" src="https://github.com/apache/spark/assets/15246973/04afd931-72a2-4ba7-8bc8-2e89cc589999">
   <img width="1116" alt="image" src="https://github.com/apache/spark/assets/15246973/37f64ec8-268a-42ff-aba1-b8a404b1ebca">
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "allanf-db (via GitHub)" <gi...@apache.org>.
allanf-db commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1409864256


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation

Review Comment:
   I prefer "Creating DataFrames" to use an active verb, implying action and engagement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1410102871


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|

Review Comment:
   Let's add some comments and highlight it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43897:
URL: https://github.com/apache/spark/pull/43897#issuecomment-1833456493

   All done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1410057838


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.

Review Comment:
   Okay, Let's delete it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-45861][PYTHON][DOCS] Add user guide for dataframe creation [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #43897:
URL: https://github.com/apache/spark/pull/43897#discussion_r1410058936


##########
python/docs/source/user_guide/sql/dataframe_creation.rst:
##########
@@ -0,0 +1,239 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+==================
+DataFrame Creation
+==================
+
+.. currentmodule:: pyspark.sql
+
+Creating through `createDataFrame`
+----------------------------------
+
+A PySpark :class:`DataFrame` can be created via :meth:`SparkSession.createDataFrame` typically by passing
+a list of lists, tuples, dictionaries and :class:`Row`, a pandas :class:`pandas.DataFrame`,
+a NumPy :class:`numpy.ndarray` and an :class:`pyspark.RDD`.
+:meth:`SparkSession.createDataFrame` takes the `schema` argument to specify the schema of the :class:`DataFrame`.
+When it is omitted, PySpark infers the corresponding schema by taking a sample from the data.
+
+Creating a PySpark :class:`DataFrame` from a list of lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: python
+
+    >>> df = spark.createDataFrame([['Alice', 1], ['Bob', 5]])
+    >>> df.show()
+    +-----+---+
+    |   _1| _2|
+    +-----+---+
+    |Alice|  1|
+    |  Bob|  5|
+    +-----+---+
+
+
+Creating a PySpark :class:`DataFrame` from a list of tuples

Review Comment:
   Delete it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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