TheNeuralBit commented on a change in pull request #15074:
URL: https://github.com/apache/beam/pull/15074#discussion_r658220348



##########
File path: 
website/www/site/content/en/documentation/dsls/dataframes/differences-from-pandas.md
##########
@@ -0,0 +1,90 @@
+---
+type: languages
+title: "Differences from pandas"
+---
+<!--
+Licensed 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.
+-->
+
+# Differences from pandas
+
+The Apache Beam DataFrame API aims to be a drop-in replacement for pandas, but 
there are a few differences to be aware of. This page describes divergences 
between the Beam and pandas APIs and provides tips for working with the Beam 
DataFrame API.
+
+## Working with pandas sources
+
+Beam operations are always associated with a pipeline. To read source data 
into a Beam DataFrame, you have to apply the source to a pipeline object. For 
example, to read input from a CSV file, you could use 
[read_csv](https://beam.apache.org/releases/pydoc/{{< param release_latest 
>}}/apache_beam.dataframe.io.html#apache_beam.dataframe.io.read_csv) as follows:
+
+    df = p | beam.dataframe.io.read_csv(...)
+
+This is similar to pandas 
[read_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html),
 but `df` is a deferred Beam DataFrame representing the contents of the file. 
The input filename can be any file pattern understood by 
[fileio.MatchFiles](https://beam.apache.org/releases/pydoc/{{< param 
release_latest >}}/apache_beam.io.fileio.html#apache_beam.io.fileio.MatchFiles).
+
+For an example of using sources and sinks with the DataFrame API, see 
[taxiride.py](https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/dataframe/taxiride.py).
+
+## Classes of unsupported operations
+
+The sections below describe classes of operations that are not supported, or 
not yet supported, by Beam DataFrame. Workarounds are suggested, where 
applicable.
+
+### Non-parallelizable operations
+
+To support distributed processing, Beam invokes DataFrame operations on 
subsets of data in parallel. Some DataFrame operations can’t be parallelized, 
and these operations raise a 
[NonParallelOperation](https://beam.apache.org/releases/pydoc/{{< param 
release_latest 
>}}/apache_beam.dataframe.expressions.html#apache_beam.dataframe.expressions.NonParallelOperation)
 error by default.
+
+**Workaround**
+
+If you want to use a non-parallelizable operation, you can guard it with a 
`beam.dataframe.allow_non_parallel_operations` block. For example:
+
+    with beam.dataframe.allow_non_parallel_operations:
+      quantiles = df.quantile()

Review comment:
       ```suggestion
       from apache_beam import dataframe
       
       with dataframe.allow_non_parallel_operations():
         quantiles = df.quantile()
   ```

##########
File path: 
website/www/site/content/en/documentation/dsls/dataframes/differences-from-pandas.md
##########
@@ -0,0 +1,90 @@
+---
+type: languages
+title: "Differences from pandas"
+---
+<!--
+Licensed 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.
+-->
+
+# Differences from pandas
+
+The Apache Beam DataFrame API aims to be a drop-in replacement for pandas, but 
there are a few differences to be aware of. This page describes divergences 
between the Beam and pandas APIs and provides tips for working with the Beam 
DataFrame API.
+
+## Working with pandas sources
+
+Beam operations are always associated with a pipeline. To read source data 
into a Beam DataFrame, you have to apply the source to a pipeline object. For 
example, to read input from a CSV file, you could use 
[read_csv](https://beam.apache.org/releases/pydoc/{{< param release_latest 
>}}/apache_beam.dataframe.io.html#apache_beam.dataframe.io.read_csv) as follows:
+
+    df = p | beam.dataframe.io.read_csv(...)
+
+This is similar to pandas 
[read_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html),
 but `df` is a deferred Beam DataFrame representing the contents of the file. 
The input filename can be any file pattern understood by 
[fileio.MatchFiles](https://beam.apache.org/releases/pydoc/{{< param 
release_latest >}}/apache_beam.io.fileio.html#apache_beam.io.fileio.MatchFiles).
+
+For an example of using sources and sinks with the DataFrame API, see 
[taxiride.py](https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/dataframe/taxiride.py).
+
+## Classes of unsupported operations
+
+The sections below describe classes of operations that are not supported, or 
not yet supported, by Beam DataFrame. Workarounds are suggested, where 
applicable.

Review comment:
       ```suggestion
   The sections below describe classes of operations that are not supported, or 
not yet supported, by the Beam DataFrame API. Workarounds are suggested, where 
applicable.
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to