Skip to content

Commit bc0e507

Browse files
authored
De-privatize (#36107)
1 parent fadb72c commit bc0e507

File tree

24 files changed

+81
-83
lines changed

24 files changed

+81
-83
lines changed

pandas/_libs/indexing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cdef class _NDFrameIndexerBase:
1+
cdef class NDFrameIndexerBase:
22
"""
33
A base class for _NDFrameIndexer for fast instantiation and attribute access.
44
"""

pandas/_libs/tslibs/parsing.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ class _timelex:
771771
_DATEUTIL_LEXER_SPLIT = _timelex.split
772772

773773

774-
def _format_is_iso(f) -> bint:
774+
def format_is_iso(f: str) -> bint:
775775
"""
776776
Does format match the iso8601 set that can be handled by the C parser?
777777
Generally of form YYYY-MM-DDTHH:MM:SS - date separator can be different
@@ -789,7 +789,7 @@ def _format_is_iso(f) -> bint:
789789
return False
790790

791791

792-
def _guess_datetime_format(
792+
def guess_datetime_format(
793793
dt_str,
794794
bint dayfirst=False,
795795
dt_str_parse=du_parse,

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@ def astype(self, dtype, copy=True):
602602
# Rendering Methods
603603

604604
def _format_native_types(self, na_rep="NaT", date_format=None, **kwargs):
605-
from pandas.io.formats.format import _get_format_datetime64_from_values
605+
from pandas.io.formats.format import get_format_datetime64_from_values
606606

607-
fmt = _get_format_datetime64_from_values(self, date_format)
607+
fmt = get_format_datetime64_from_values(self, date_format)
608608

609609
return tslib.format_array_from_datetime(
610610
self.asi8.ravel(), tz=self.tz, format=fmt, na_rep=na_rep

pandas/core/arrays/timedeltas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,14 @@ def median(
379379
# Rendering Methods
380380

381381
def _formatter(self, boxed=False):
382-
from pandas.io.formats.format import _get_format_timedelta64
382+
from pandas.io.formats.format import get_format_timedelta64
383383

384-
return _get_format_timedelta64(self, box=True)
384+
return get_format_timedelta64(self, box=True)
385385

386386
def _format_native_types(self, na_rep="NaT", date_format=None, **kwargs):
387-
from pandas.io.formats.format import _get_format_timedelta64
387+
from pandas.io.formats.format import get_format_timedelta64
388388

389-
formatter = _get_format_timedelta64(self._data, na_rep)
389+
formatter = get_format_timedelta64(self._data, na_rep)
390390
return np.array([formatter(x) for x in self._data.ravel()]).reshape(self.shape)
391391

392392
# ----------------------------------------------------------------

pandas/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
ABCIndexClass,
3232
ABCSeries,
3333
)
34-
from pandas.core.dtypes.inference import _iterable_not_string
34+
from pandas.core.dtypes.inference import iterable_not_string
3535
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
3636

3737

@@ -61,7 +61,7 @@ def flatten(l):
6161
flattened : generator
6262
"""
6363
for el in l:
64-
if _iterable_not_string(el):
64+
if iterable_not_string(el):
6565
for s in flatten(el):
6666
yield s
6767
else:

pandas/core/computation/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pandas._config import get_option
66

77

8-
def _ensure_decoded(s):
8+
def ensure_decoded(s):
99
"""
1010
If we have bytes, decode them to unicode.
1111
"""

pandas/core/computation/ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pandas.core.dtypes.common import is_list_like, is_scalar
1616

1717
import pandas.core.common as com
18-
from pandas.core.computation.common import _ensure_decoded, result_type_many
18+
from pandas.core.computation.common import ensure_decoded, result_type_many
1919
from pandas.core.computation.scope import _DEFAULT_GLOBALS
2020

2121
from pandas.io.formats.printing import pprint_thing, pprint_thing_encoded
@@ -466,7 +466,7 @@ def stringify(value):
466466
v = rhs.value
467467
if isinstance(v, (int, float)):
468468
v = stringify(v)
469-
v = Timestamp(_ensure_decoded(v))
469+
v = Timestamp(ensure_decoded(v))
470470
if v.tz is not None:
471471
v = v.tz_convert("UTC")
472472
self.rhs.update(v)
@@ -475,7 +475,7 @@ def stringify(value):
475475
v = lhs.value
476476
if isinstance(v, (int, float)):
477477
v = stringify(v)
478-
v = Timestamp(_ensure_decoded(v))
478+
v = Timestamp(ensure_decoded(v))
479479
if v.tz is not None:
480480
v = v.tz_convert("UTC")
481481
self.lhs.update(v)

pandas/core/computation/pytables.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pandas as pd
1515
import pandas.core.common as com
1616
from pandas.core.computation import expr, ops, scope as _scope
17-
from pandas.core.computation.common import _ensure_decoded
17+
from pandas.core.computation.common import ensure_decoded
1818
from pandas.core.computation.expr import BaseExprVisitor
1919
from pandas.core.computation.ops import UndefinedVariableError, is_term
2020
from pandas.core.construction import extract_array
@@ -189,12 +189,12 @@ def stringify(value):
189189
encoder = pprint_thing
190190
return encoder(value)
191191

192-
kind = _ensure_decoded(self.kind)
193-
meta = _ensure_decoded(self.meta)
192+
kind = ensure_decoded(self.kind)
193+
meta = ensure_decoded(self.meta)
194194
if kind == "datetime64" or kind == "datetime":
195195
if isinstance(v, (int, float)):
196196
v = stringify(v)
197-
v = _ensure_decoded(v)
197+
v = ensure_decoded(v)
198198
v = Timestamp(v)
199199
if v.tz is not None:
200200
v = v.tz_convert("UTC")

pandas/core/dtypes/common.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ def is_dtype_equal(source, target) -> bool:
635635
False
636636
"""
637637
try:
638-
source = _get_dtype(source)
639-
target = _get_dtype(target)
638+
source = get_dtype(source)
639+
target = get_dtype(target)
640640
return source == target
641641
except (TypeError, AttributeError):
642642

@@ -984,10 +984,10 @@ def is_datetime64_ns_dtype(arr_or_dtype) -> bool:
984984
if arr_or_dtype is None:
985985
return False
986986
try:
987-
tipo = _get_dtype(arr_or_dtype)
987+
tipo = get_dtype(arr_or_dtype)
988988
except TypeError:
989989
if is_datetime64tz_dtype(arr_or_dtype):
990-
tipo = _get_dtype(arr_or_dtype.dtype)
990+
tipo = get_dtype(arr_or_dtype.dtype)
991991
else:
992992
return False
993993
return tipo == DT64NS_DTYPE or getattr(tipo, "base", None) == DT64NS_DTYPE
@@ -1372,7 +1372,7 @@ def is_bool_dtype(arr_or_dtype) -> bool:
13721372
if arr_or_dtype is None:
13731373
return False
13741374
try:
1375-
dtype = _get_dtype(arr_or_dtype)
1375+
dtype = get_dtype(arr_or_dtype)
13761376
except TypeError:
13771377
return False
13781378

@@ -1557,13 +1557,13 @@ def _is_dtype(arr_or_dtype, condition) -> bool:
15571557
if arr_or_dtype is None:
15581558
return False
15591559
try:
1560-
dtype = _get_dtype(arr_or_dtype)
1560+
dtype = get_dtype(arr_or_dtype)
15611561
except (TypeError, ValueError, UnicodeEncodeError):
15621562
return False
15631563
return condition(dtype)
15641564

15651565

1566-
def _get_dtype(arr_or_dtype) -> DtypeObj:
1566+
def get_dtype(arr_or_dtype) -> DtypeObj:
15671567
"""
15681568
Get the dtype instance associated with an array
15691569
or dtype object.
@@ -1694,7 +1694,7 @@ def infer_dtype_from_object(dtype):
16941694
try:
16951695
return infer_dtype_from_object(getattr(np, dtype))
16961696
except (AttributeError, TypeError):
1697-
# Handles cases like _get_dtype(int) i.e.,
1697+
# Handles cases like get_dtype(int) i.e.,
16981698
# Python objects that are valid dtypes
16991699
# (unlike user-defined types, in general)
17001700
#

pandas/core/dtypes/inference.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def is_number(obj) -> bool:
6868
return isinstance(obj, (Number, np.number))
6969

7070

71-
def _iterable_not_string(obj) -> bool:
71+
def iterable_not_string(obj) -> bool:
7272
"""
7373
Check if the object is an iterable but not a string.
7474
@@ -83,11 +83,11 @@ def _iterable_not_string(obj) -> bool:
8383
8484
Examples
8585
--------
86-
>>> _iterable_not_string([1, 2, 3])
86+
>>> iterable_not_string([1, 2, 3])
8787
True
88-
>>> _iterable_not_string("foo")
88+
>>> iterable_not_string("foo")
8989
False
90-
>>> _iterable_not_string(1)
90+
>>> iterable_not_string(1)
9191
False
9292
"""
9393
return isinstance(obj, abc.Iterable) and not isinstance(obj, str)

0 commit comments

Comments
 (0)