@@ -351,10 +351,10 @@ def _datetime_to_stata_elapsed_vec(dates: Series, fmt: str) -> Series:
351
351
352
352
def parse_dates_safe (dates , delta = False , year = False , days = False ):
353
353
d = {}
354
- if is_datetime64_dtype (dates .values ):
354
+ if is_datetime64_dtype (dates .dtype ):
355
355
if delta :
356
356
time_delta = dates - stata_epoch
357
- d ["delta" ] = time_delta .values .astype (np .int64 ) // 1000 # microseconds
357
+ d ["delta" ] = time_delta ._values .astype (np .int64 ) // 1000 # microseconds
358
358
if days or year :
359
359
# ignore since mypy reports that DatetimeIndex has no year/month
360
360
date_index = DatetimeIndex (dates )
@@ -368,7 +368,7 @@ def parse_dates_safe(dates, delta=False, year=False, days=False):
368
368
369
369
elif infer_dtype (dates , skipna = False ) == "datetime" :
370
370
if delta :
371
- delta = dates .values - stata_epoch
371
+ delta = dates ._values - stata_epoch
372
372
373
373
def f (x : datetime .timedelta ) -> float :
374
374
return US_PER_DAY * x .days + 1000000 * x .seconds + x .microseconds
@@ -377,8 +377,8 @@ def f(x: datetime.timedelta) -> float:
377
377
d ["delta" ] = v (delta )
378
378
if year :
379
379
year_month = dates .apply (lambda x : 100 * x .year + x .month )
380
- d ["year" ] = year_month .values // 100
381
- d ["month" ] = year_month .values - d ["year" ] * 100
380
+ d ["year" ] = year_month ._values // 100
381
+ d ["month" ] = year_month ._values - d ["year" ] * 100
382
382
if days :
383
383
384
384
def g (x : datetime .datetime ) -> int :
@@ -1956,7 +1956,7 @@ def _dtype_to_stata_type(dtype: np.dtype, column: Series) -> int:
1956
1956
if dtype .type == np .object_ : # try to coerce it to the biggest string
1957
1957
# not memory efficient, what else could we
1958
1958
# do?
1959
- itemsize = max_len_string_array (ensure_object (column .values ))
1959
+ itemsize = max_len_string_array (ensure_object (column ._values ))
1960
1960
return max (itemsize , 1 )
1961
1961
elif dtype == np .float64 :
1962
1962
return 255
@@ -1998,7 +1998,7 @@ def _dtype_to_default_stata_fmt(
1998
1998
if force_strl :
1999
1999
return "%9s"
2000
2000
if dtype .type == np .object_ :
2001
- itemsize = max_len_string_array (ensure_object (column .values ))
2001
+ itemsize = max_len_string_array (ensure_object (column ._values ))
2002
2002
if itemsize > max_str_len :
2003
2003
if dta_version >= 117 :
2004
2004
return "%9s"
@@ -2151,7 +2151,7 @@ def _prepare_categoricals(self, data: DataFrame) -> DataFrame:
2151
2151
"It is not possible to export "
2152
2152
"int64-based categorical data to Stata."
2153
2153
)
2154
- values = data [col ].cat .codes .values .copy ()
2154
+ values = data [col ].cat .codes ._values .copy ()
2155
2155
2156
2156
# Upcast if needed so that correct missing values can be set
2157
2157
if values .max () >= get_base_missing_value (dtype ):
@@ -2384,7 +2384,7 @@ def _encode_strings(self) -> None:
2384
2384
encoded = self .data [col ].str .encode (self ._encoding )
2385
2385
# If larger than _max_string_length do nothing
2386
2386
if (
2387
- max_len_string_array (ensure_object (encoded .values ))
2387
+ max_len_string_array (ensure_object (encoded ._values ))
2388
2388
<= self ._max_string_length
2389
2389
):
2390
2390
self .data [col ] = encoded
@@ -2650,7 +2650,7 @@ def _dtype_to_stata_type_117(dtype: np.dtype, column: Series, force_strl: bool)
2650
2650
if dtype .type == np .object_ : # try to coerce it to the biggest string
2651
2651
# not memory efficient, what else could we
2652
2652
# do?
2653
- itemsize = max_len_string_array (ensure_object (column .values ))
2653
+ itemsize = max_len_string_array (ensure_object (column ._values ))
2654
2654
itemsize = max (itemsize , 1 )
2655
2655
if itemsize <= 2045 :
2656
2656
return itemsize
0 commit comments