@@ -1678,13 +1678,6 @@ def from_arrow_schema(arrow_schema):
16781678 for field in arrow_schema ])
16791679
16801680
1681- def _old_pandas_exception_message (e ):
1682- """ Create an error message for importing old Pandas.
1683- """
1684- msg = "note: Pandas (>=0.19.2) must be installed and available on calling Python process"
1685- return "%s\n %s" % (_exception_message (e ), msg )
1686-
1687-
16881681def _check_dataframe_localize_timestamps (pdf , timezone ):
16891682 """
16901683 Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone
@@ -1693,10 +1686,10 @@ def _check_dataframe_localize_timestamps(pdf, timezone):
16931686 :param timezone: the timezone to convert. if None then use local timezone
16941687 :return pandas.DataFrame where any timezone aware columns have been converted to tz-naive
16951688 """
1696- try :
1697- from pandas . api . types import is_datetime64tz_dtype
1698- except ImportError as e :
1699- raise ImportError ( _old_pandas_exception_message ( e ))
1689+ from pyspark . sql . utils import _require_minimum_pandas_version
1690+ _require_minimum_pandas_version ()
1691+
1692+ from pandas . api . types import is_datetime64tz_dtype
17001693 tz = timezone or 'tzlocal()'
17011694 for column , series in pdf .iteritems ():
17021695 # TODO: handle nested timestamps, such as ArrayType(TimestampType())?
@@ -1714,10 +1707,10 @@ def _check_series_convert_timestamps_internal(s, timezone):
17141707 :param timezone: the timezone to convert. if None then use local timezone
17151708 :return pandas.Series where if it is a timestamp, has been UTC normalized without a time zone
17161709 """
1717- try :
1718- from pandas . api . types import is_datetime64_dtype , is_datetime64tz_dtype
1719- except ImportError as e :
1720- raise ImportError ( _old_pandas_exception_message ( e ))
1710+ from pyspark . sql . utils import _require_minimum_pandas_version
1711+ _require_minimum_pandas_version ()
1712+
1713+ from pandas . api . types import is_datetime64_dtype , is_datetime64tz_dtype
17211714 # TODO: handle nested timestamps, such as ArrayType(TimestampType())?
17221715 if is_datetime64_dtype (s .dtype ):
17231716 tz = timezone or 'tzlocal()'
@@ -1737,11 +1730,11 @@ def _check_series_convert_timestamps_localize(s, from_timezone, to_timezone):
17371730 :param to_timezone: the timezone to convert to. if None then use local timezone
17381731 :return pandas.Series where if it is a timestamp, has been converted to tz-naive
17391732 """
1740- try :
1741- import pandas as pd
1742- from pandas . api . types import is_datetime64tz_dtype , is_datetime64_dtype
1743- except ImportError as e :
1744- raise ImportError ( _old_pandas_exception_message ( e ))
1733+ from pyspark . sql . utils import _require_minimum_pandas_version
1734+ _require_minimum_pandas_version ()
1735+
1736+ import pandas as pd
1737+ from pandas . api . types import is_datetime64tz_dtype , is_datetime64_dtype
17451738 from_tz = from_timezone or 'tzlocal()'
17461739 to_tz = to_timezone or 'tzlocal()'
17471740 # TODO: handle nested timestamps, such as ArrayType(TimestampType())?
0 commit comments