Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-36265][PYTHON] Use __getitem__ instead of getItem to suppress warnings #33486

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/pyspark/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ def factorize(
)
)
map_scol = F.create_map(*kvs)
scol = map_scol.getItem(self.spark.column)
scol = map_scol[self.spark.column]
codes, uniques = self._with_new_scol(
scol.alias(self._internal.data_spark_column_names[0])
).factorize(na_sentinel=na_sentinel)
Expand Down Expand Up @@ -1636,7 +1636,7 @@ def factorize(
map_scol = F.create_map(*kvs)

null_scol = F.when(cond, SF.lit(na_sentinel_code))
new_scol = null_scol.otherwise(map_scol.getItem(scol))
new_scol = null_scol.otherwise(map_scol[scol])

codes = self._with_new_scol(new_scol.alias(self._internal.data_spark_column_names[0]))

Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/pandas/data_type_ops/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _as_categorical_type(
)
map_scol = F.create_map(*kvs)

scol = F.coalesce(map_scol.getItem(index_ops.spark.column), SF.lit(-1))
scol = F.coalesce(map_scol[index_ops.spark.column], SF.lit(-1))
return index_ops._with_new_scol(
scol.cast(spark_type),
field=index_ops._internal.data_fields[0].copy(
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/pandas/data_type_ops/categorical_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def astype(self, index_ops: IndexOpsLike, dtype: Union[str, type, Dtype]) -> Ind
*[(SF.lit(code), SF.lit(category)) for code, category in enumerate(categories)]
)
map_scol = F.create_map(*kvs)
scol = map_scol.getItem(index_ops.spark.column)
scol = map_scol[index_ops.spark.column]
return index_ops._with_new_scol(scol).astype(dtype)

def eq(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/pandas/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10854,7 +10854,7 @@ def quantile(spark_column: Column, spark_type: DataType) -> Column:
for column in percentile_col_names:
cols_dict[column] = list()
for i in range(len(qq)):
cols_dict[column].append(scol_for(sdf, column).getItem(i).alias(column))
cols_dict[column].append(scol_for(sdf, column)[i].alias(column))

internal_index_column = SPARK_DEFAULT_INDEX_NAME
cols = []
Expand Down