xinrong-databricks commented on a change in pull request #34314: URL: https://github.com/apache/spark/pull/34314#discussion_r732122349
########## File path: python/pyspark/pandas/tests/data_type_ops/test_num_ops.py ########## @@ -344,40 +334,35 @@ def test_from_to_pandas(self): self.assert_eq(ps.from_pandas(pser), psser) def test_isnull(self): - pdf, psdf = self.numeric_w_nan_pdf, self.numeric_w_nan_psdf - for col in self.numeric_w_nan_df_cols: + pdf, psdf = self.pdf, self.psdf + for col in self.numeric_df_cols: self.assert_eq(pdf[col].isnull(), psdf[col].isnull()) def test_astype(self): pdf, psdf = self.pdf, self.psdf for col in self.numeric_df_cols: pser, psser = pdf[col], psdf[col] - self.assert_eq(pser.astype(int), psser.astype(int)) + if not pser.hasnans: + self.assert_eq(pser.astype(int), psser.astype(int)) + self.assert_eq(pser.astype(np.int32), psser.astype(np.int32)) + self.assert_eq(pser.astype(np.int16), psser.astype(np.int16)) + self.assert_eq(pser.astype(np.int8), psser.astype(np.int8)) + # TODO(SPARK-37039): the np.nan series.astype(bool) should be True + self.assert_eq(pser.astype(bool), psser.astype(bool)) + else: + for int_type in [int, np.int32, np.int16, np.int8]: + self.assertRaisesRegex( + ValueError, + "Cannot convert %s with missing " + "values to integer" % psser._dtype_op.pretty_name, Review comment: Nice! -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org