Python pandas.core.dtypes.inference.is_list_like() Examples
The following are 18
code examples of pandas.core.dtypes.inference.is_list_like().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.core.dtypes.inference
, or try the search function
.
Example #1
Source File: numpy_.py From recruit with Apache License 2.0 | 6 votes |
def __setitem__(self, key, value): from pandas.core.internals.arrays import extract_array value = extract_array(value, extract_numpy=True) if not lib.is_scalar(key) and is_list_like(key): key = np.asarray(key) if not lib.is_scalar(value): value = np.asarray(value) values = self._ndarray t = np.result_type(value, values) if t != self._ndarray.dtype: values = values.astype(t, casting='safe') values[key] = value self._dtype = PandasDtype(t) self._ndarray = values else: self._ndarray[key] = value
Example #2
Source File: numpy_.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def __setitem__(self, key, value): from pandas.core.internals.arrays import extract_array value = extract_array(value, extract_numpy=True) if not lib.is_scalar(key) and is_list_like(key): key = np.asarray(key) if not lib.is_scalar(value): value = np.asarray(value) values = self._ndarray t = np.result_type(value, values) if t != self._ndarray.dtype: values = values.astype(t, casting='safe') values[key] = value self._dtype = PandasDtype(t) self._ndarray = values else: self._ndarray[key] = value
Example #3
Source File: test_inference.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_is_nested_list_like_passes(inner, outer): result = outer([inner for _ in range(5)]) assert inference.is_list_like(result)
Example #4
Source File: test_inference.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_is_nested_list_like_passes(inner, outer): result = outer([inner for _ in range(5)]) assert inference.is_list_like(result)
Example #5
Source File: test_inference.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_is_list_like_fails(ll): assert not inference.is_list_like(ll)
Example #6
Source File: test_inference.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_is_list_like_passes(ll): assert inference.is_list_like(ll)
Example #7
Source File: field_mappings.py From eland with Apache License 2.0 | 5 votes |
def _set_display_names(self, display_names): if not is_list_like(display_names): raise ValueError(f"'{display_names}' is not list like") if list(set(display_names) - set(self.display_names)): raise KeyError(f"{display_names} not in display names {self.display_names}") self._mappings_capabilities = self._mappings_capabilities.reindex(display_names)
Example #8
Source File: test_inference.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_is_nested_list_like_passes(inner, outer): result = outer([inner for _ in range(5)]) assert inference.is_list_like(result)
Example #9
Source File: test_inference.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_is_list_like(): passes = ([], [1], (1, ), (1, 2), {'a': 1}, set([1, 'a']), Series([1]), Series([]), Series(['a']).str) fails = (1, '2', object(), str) for p in passes: assert inference.is_list_like(p) for f in fails: assert not inference.is_list_like(f)
Example #10
Source File: plot.py From koalas with Apache License 2.0 | 5 votes |
def _args_adjust(self): if is_list_like(self.bottom): self.bottom = np.array(self.bottom)
Example #11
Source File: test_inference.py From recruit with Apache License 2.0 | 5 votes |
def test_is_list_like(maybe_list_like): obj, expected = maybe_list_like expected = True if expected == 'set' else expected assert inference.is_list_like(obj) == expected
Example #12
Source File: test_inference.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_is_list_like_disallow_sets(maybe_list_like): obj, expected = maybe_list_like expected = False if expected == 'set' else expected assert inference.is_list_like(obj, allow_sets=False) == expected
Example #13
Source File: test_inference.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_is_list_like(maybe_list_like): obj, expected = maybe_list_like expected = True if expected == 'set' else expected assert inference.is_list_like(obj) == expected
Example #14
Source File: test_inference.py From vnpy_crypto with MIT License | 5 votes |
def test_is_nested_list_like_passes(inner, outer): result = outer([inner for _ in range(5)]) assert inference.is_list_like(result)
Example #15
Source File: test_inference.py From vnpy_crypto with MIT License | 5 votes |
def test_is_list_like_fails(ll): assert not inference.is_list_like(ll)
Example #16
Source File: test_inference.py From vnpy_crypto with MIT License | 5 votes |
def test_is_list_like_passes(ll): assert inference.is_list_like(ll)
Example #17
Source File: test_inference.py From recruit with Apache License 2.0 | 5 votes |
def test_is_nested_list_like_passes(inner, outer): result = outer([inner for _ in range(5)]) assert inference.is_list_like(result)
Example #18
Source File: test_inference.py From recruit with Apache License 2.0 | 5 votes |
def test_is_list_like_disallow_sets(maybe_list_like): obj, expected = maybe_list_like expected = False if expected == 'set' else expected assert inference.is_list_like(obj, allow_sets=False) == expected