You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2020/06/25 11:18:00 UTC
[jira] [Commented] (SPARK-32098) Use iloc for positional slicing
instead of direct slicing in createDataFrame with Arrow
[ https://issues.apache.org/jira/browse/SPARK-32098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17144850#comment-17144850 ]
Apache Spark commented on SPARK-32098:
--------------------------------------
User 'HyukjinKwon' has created a pull request for this issue:
https://github.com/apache/spark/pull/28928
> Use iloc for positional slicing instead of direct slicing in createDataFrame with Arrow
> ---------------------------------------------------------------------------------------
>
> Key: SPARK-32098
> URL: https://issues.apache.org/jira/browse/SPARK-32098
> Project: Spark
> Issue Type: Improvement
> Components: PySpark
> Affects Versions: 2.4.6, 3.0.0
> Reporter: Hyukjin Kwon
> Priority: Critical
> Labels: correctness
>
> When you use floats are index of pandas, it produces a wrong results:
> {code}
> >>> import pandas as pd
> >>> spark.createDataFrame(pd.DataFrame({'a': [1,2,3]}, index=[2., 3., 4.])).show()
> +---+
> | a|
> +---+
> | 1|
> | 1|
> | 2|
> +---+
> {code}
> This is because direct slicing uses the value as index when the index contains floats:
> {code}
> >>> pd.DataFrame({'a': [1,2,3]}, index=[2., 3., 4.])[2:]
> a
> 2.0 1
> 3.0 2
> 4.0 3
> >>> pd.DataFrame({'a': [1,2,3]}, index=[2., 3., 4.]).iloc[2:]
> a
> 4.0 3
> >>> pd.DataFrame({'a': [1,2,3]}, index=[2, 3, 4])[2:]
> a
> 4 3
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org