xinrong-databricks commented on code in PR #36793:
URL: https://github.com/apache/spark/pull/36793#discussion_r895210608
##########
python/pyspark/sql/session.py:
##########
@@ -952,12 +953,29 @@ def createDataFrame( # type: ignore[misc]
schema = [x.encode("utf-8") if not isinstance(x, str) else x for x
in schema]
try:
- import pandas
+ import pandas as pd
has_pandas = True
except Exception:
has_pandas = False
- if has_pandas and isinstance(data, pandas.DataFrame):
+
+ try:
+ import numpy as np
+
+ has_numpy = True
+ except Exception:
+ has_numpy = False
+
+ if has_numpy and isinstance(data, np.ndarray):
+ from pyspark.sql.pandas.utils import require_minimum_pandas_version
+
+ require_minimum_pandas_version()
Review Comment:
What you suggested makes sense.
My concern is that
```py
if not has_pandas:
// warning or raised friendly exception
```
overlaps with the `require_minimum_pandas_version` check, since the latter
checks `has_pandas` as well.
I will leave a note for now and we may follow up with a better approach
later. WDYT :)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]