|
5 | 5 | import pandas
|
6 | 6 | from pandas.api.types import is_scalar
|
7 | 7 | from pandas.compat import to_str, string_types, numpy as numpy_compat, cPickle as pkl
|
8 |
| -import pandas.core.common as com |
| 8 | +from pandas.core.common import count_not_none, _pipe, apply_if_callable, is_bool_indexer |
9 | 9 | from pandas.core.dtypes.common import (
|
10 |
| - _get_dtype_from_object, |
| 10 | + infer_dtype_from_object, |
11 | 11 | is_list_like,
|
12 | 12 | is_numeric_dtype,
|
13 | 13 | is_datetime_or_timedelta_dtype,
|
14 | 14 | is_dtype_equal,
|
15 | 15 | is_object_dtype,
|
16 | 16 | is_integer_dtype,
|
17 | 17 | )
|
18 |
| -from pandas.core.index import _ensure_index_from_sequences |
| 18 | +from pandas.core.index import ensure_index_from_sequences |
19 | 19 | from pandas.core.indexing import check_bool_indexer, convert_to_index_sliceable
|
20 | 20 | from pandas.util._validators import validate_bool_kwarg
|
21 | 21 |
|
@@ -769,13 +769,7 @@ def apply(
|
769 | 769 | FutureWarning,
|
770 | 770 | stacklevel=2,
|
771 | 771 | )
|
772 |
| - elif is_list_like(func): |
773 |
| - if axis == 1: |
774 |
| - raise TypeError( |
775 |
| - "(\"'list' object is not callable\", " |
776 |
| - "'occurred at index {0}'".format(self.index[0]) |
777 |
| - ) |
778 |
| - elif not callable(func): |
| 772 | + elif not callable(func) and not is_list_like(func): |
779 | 773 | return
|
780 | 774 |
|
781 | 775 | query_compiler = self._query_compiler.apply(func, axis, *args, **kwds)
|
@@ -1512,7 +1506,7 @@ def filter(self, items=None, like=None, regex=None, axis=None):
|
1512 | 1506 | Returns:
|
1513 | 1507 | A new DataFrame with the filter applied.
|
1514 | 1508 | """
|
1515 |
| - nkw = com._count_not_none(items, like, regex) |
| 1509 | + nkw = count_not_none(items, like, regex) |
1516 | 1510 | if nkw > 1:
|
1517 | 1511 | raise TypeError(
|
1518 | 1512 | "Keyword arguments `items`, `like`, or `regex` "
|
@@ -2553,7 +2547,7 @@ def pipe(self, func, *args, **kwargs):
|
2553 | 2547 | Returns:
|
2554 | 2548 | object: the return type of ``func``.
|
2555 | 2549 | """
|
2556 |
| - return com._pipe(self, func, *args, **kwargs) |
| 2550 | + return _pipe(self, func, *args, **kwargs) |
2557 | 2551 |
|
2558 | 2552 | def pivot(self, index=None, columns=None, values=None):
|
2559 | 2553 | return self._default_to_pandas(
|
@@ -3465,7 +3459,7 @@ def select_dtypes(self, include=None, exclude=None):
|
3465 | 3459 | exclude = []
|
3466 | 3460 |
|
3467 | 3461 | sel = tuple(map(set, (include, exclude)))
|
3468 |
| - include, exclude = map(lambda x: set(map(_get_dtype_from_object, x)), sel) |
| 3462 | + include, exclude = map(lambda x: set(map(infer_dtype_from_object, x)), sel) |
3469 | 3463 | include_these = pandas.Series(not bool(include), index=self.columns)
|
3470 | 3464 | exclude_these = pandas.Series(not bool(exclude), index=self.columns)
|
3471 | 3465 |
|
@@ -3595,7 +3589,7 @@ def set_index(
|
3595 | 3589 | if drop:
|
3596 | 3590 | to_remove.append(col)
|
3597 | 3591 | arrays.append(level)
|
3598 |
| - index = _ensure_index_from_sequences(arrays, names) |
| 3592 | + index = ensure_index_from_sequences(arrays, names) |
3599 | 3593 |
|
3600 | 3594 | if verify_integrity and not index.is_unique:
|
3601 | 3595 | duplicates = index.get_duplicates()
|
@@ -4500,7 +4494,7 @@ def __getitem__(self, key):
|
4500 | 4494 | Returns:
|
4501 | 4495 | A Pandas Series representing the value for the column.
|
4502 | 4496 | """
|
4503 |
| - key = com._apply_if_callable(key, self) |
| 4497 | + key = apply_if_callable(key, self) |
4504 | 4498 | # Shortcut if key is an actual column
|
4505 | 4499 | is_mi_columns = isinstance(self.columns, pandas.MultiIndex)
|
4506 | 4500 | try:
|
@@ -4529,7 +4523,7 @@ def _getitem_column(self, key):
|
4529 | 4523 | )
|
4530 | 4524 |
|
4531 | 4525 | def _getitem_array(self, key):
|
4532 |
| - if com.is_bool_indexer(key): |
| 4526 | + if is_bool_indexer(key): |
4533 | 4527 | if isinstance(key, pandas.Series) and not key.index.equals(self.index):
|
4534 | 4528 | warnings.warn(
|
4535 | 4529 | "Boolean Series key will be reindexed to match DataFrame index.",
|
|
0 commit comments