Python pandas.core.common._all_none() Examples
The following are 21
code examples of pandas.core.common._all_none().
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.common
, or try the search function
.
Example #1
Source File: test_util.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_set_locale(self): if len(self.locales) == 1: pytest.skip("Only a single locale found, no point in " "trying to test setting another locale") if com._all_none(*self.current_locale): # Not sure why, but on some travis runs with pytest, # getlocale() returned (None, None). pytest.skip("Current locale is not set.") locale_override = os.environ.get('LOCALE_OVERRIDE', None) if locale_override is None: lang, enc = 'it_CH', 'UTF-8' elif locale_override == 'C': lang, enc = 'en_US', 'ascii' else: lang, enc = locale_override.split('.') enc = codecs.lookup(enc).name new_locale = lang, enc if not tm._can_set_locale(new_locale): with pytest.raises(locale.Error): with tm.set_locale(new_locale): pass else: with tm.set_locale(new_locale) as normalized_locale: new_lang, new_enc = normalized_locale.split('.') new_enc = codecs.lookup(enc).name normalized_locale = new_lang, new_enc assert normalized_locale == new_locale current_locale = locale.getlocale() assert current_locale == self.current_locale
Example #2
Source File: pytables.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def delete(self, where=None, start=None, stop=None, **kwargs): """ support fully deleting the node in its entirety (only) - where specification must be None """ if _all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
Example #3
Source File: pytables.py From recruit with Apache License 2.0 | 5 votes |
def delete(self, where=None, start=None, stop=None, **kwargs): """ support fully deleting the node in its entirety (only) - where specification must be None """ if com._all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
Example #4
Source File: test_util.py From vnpy_crypto with MIT License | 5 votes |
def test_set_locale(self): if len(self.locales) == 1: pytest.skip("Only a single locale found, no point in " "trying to test setting another locale") if com._all_none(*self.current_locale): # Not sure why, but on some travis runs with pytest, # getlocale() returned (None, None). pytest.skip("Current locale is not set.") locale_override = os.environ.get('LOCALE_OVERRIDE', None) if locale_override is None: lang, enc = 'it_CH', 'UTF-8' elif locale_override == 'C': lang, enc = 'en_US', 'ascii' else: lang, enc = locale_override.split('.') enc = codecs.lookup(enc).name new_locale = lang, enc if not tm._can_set_locale(new_locale): with pytest.raises(locale.Error): with tm.set_locale(new_locale): pass else: with tm.set_locale(new_locale) as normalized_locale: new_lang, new_enc = normalized_locale.split('.') new_enc = codecs.lookup(enc).name normalized_locale = new_lang, new_enc assert normalized_locale == new_locale current_locale = locale.getlocale() assert current_locale == self.current_locale
Example #5
Source File: pytables.py From vnpy_crypto with MIT License | 5 votes |
def delete(self, where=None, start=None, stop=None, **kwargs): """ support fully deleting the node in its entirety (only) - where specification must be None """ if com._all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
Example #6
Source File: test_util.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_set_locale(self): if len(self.locales) == 1: pytest.skip("Only a single locale found, no point in " "trying to test setting another locale") if _all_none(*self.current_locale): # Not sure why, but on some travis runs with pytest, # getlocale() returned (None, None). pytest.skip("Current locale is not set.") locale_override = os.environ.get('LOCALE_OVERRIDE', None) if locale_override is None: lang, enc = 'it_CH', 'UTF-8' elif locale_override == 'C': lang, enc = 'en_US', 'ascii' else: lang, enc = locale_override.split('.') enc = codecs.lookup(enc).name new_locale = lang, enc if not tm._can_set_locale(new_locale): with pytest.raises(locale.Error): with tm.set_locale(new_locale): pass else: with tm.set_locale(new_locale) as normalized_locale: new_lang, new_enc = normalized_locale.split('.') new_enc = codecs.lookup(enc).name normalized_locale = new_lang, new_enc assert normalized_locale == new_locale current_locale = locale.getlocale() assert current_locale == self.current_locale
Example #7
Source File: test_locale.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_set_locale(): if com._all_none(_current_locale): # Not sure why, but on some Travis runs with pytest, # getlocale() returned (None, None). pytest.skip("Current locale is not set.") locale_override = os.environ.get("LOCALE_OVERRIDE", None) if locale_override is None: lang, enc = "it_CH", "UTF-8" elif locale_override == "C": lang, enc = "en_US", "ascii" else: lang, enc = locale_override.split(".") enc = codecs.lookup(enc).name new_locale = lang, enc if not tm.can_set_locale(new_locale): msg = "unsupported locale setting" with pytest.raises(locale.Error, match=msg): with tm.set_locale(new_locale): pass else: with tm.set_locale(new_locale) as normalized_locale: new_lang, new_enc = normalized_locale.split(".") new_enc = codecs.lookup(enc).name normalized_locale = new_lang, new_enc assert normalized_locale == new_locale # Once we exit the "with" statement, locale should be back to what it was. current_locale = locale.getlocale() assert current_locale == _current_locale
Example #8
Source File: test_locale.py From recruit with Apache License 2.0 | 5 votes |
def test_set_locale(): if com._all_none(_current_locale): # Not sure why, but on some Travis runs with pytest, # getlocale() returned (None, None). pytest.skip("Current locale is not set.") locale_override = os.environ.get("LOCALE_OVERRIDE", None) if locale_override is None: lang, enc = "it_CH", "UTF-8" elif locale_override == "C": lang, enc = "en_US", "ascii" else: lang, enc = locale_override.split(".") enc = codecs.lookup(enc).name new_locale = lang, enc if not tm.can_set_locale(new_locale): msg = "unsupported locale setting" with pytest.raises(locale.Error, match=msg): with tm.set_locale(new_locale): pass else: with tm.set_locale(new_locale) as normalized_locale: new_lang, new_enc = normalized_locale.split(".") new_enc = codecs.lookup(enc).name normalized_locale = new_lang, new_enc assert normalized_locale == new_locale # Once we exit the "with" statement, locale should be back to what it was. current_locale = locale.getlocale() assert current_locale == _current_locale
Example #9
Source File: pytables.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def delete(self, where=None, start=None, stop=None, **kwargs): """ support fully deleting the node in its entirety (only) - where specification must be None """ if _all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
Example #10
Source File: pytables.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def delete(self, where=None, start=None, stop=None, **kwargs): """ support fully deleting the node in its entirety (only) - where specification must be None """ if com._all_none(where, start, stop): self._handle.remove_node(self.group, recursive=True) return None raise TypeError("cannot delete on an abstract storer")
Example #11
Source File: range.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def __new__(cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None, fastpath=None): if fastpath is not None: warnings.warn("The 'fastpath' keyword is deprecated, and will be " "removed in a future version.", FutureWarning, stacklevel=2) if fastpath: return cls._simple_new(start, stop, step, name=name) cls._validate_dtype(dtype) # RangeIndex if isinstance(start, RangeIndex): if name is None: name = start.name return cls._simple_new(name=name, **dict(start._get_data_as_items())) # validate the arguments def ensure_int(value, field): msg = ("RangeIndex(...) must be called with integers," " {value} was passed for {field}") if not is_scalar(value): raise TypeError(msg.format(value=type(value).__name__, field=field)) try: new_value = int(value) assert(new_value == value) except (TypeError, ValueError, AssertionError): raise TypeError(msg.format(value=type(value).__name__, field=field)) return new_value if com._all_none(start, stop, step): msg = "RangeIndex(...) must be called with integers" raise TypeError(msg) elif start is None: start = 0 else: start = ensure_int(start, 'start') if stop is None: stop = start start = 0 else: stop = ensure_int(stop, 'stop') if step is None: step = 1 elif step == 0: raise ValueError("Step must not be zero") else: step = ensure_int(step, 'step') return cls._simple_new(start, stop, step, name)
Example #12
Source File: pytables.py From elasticintel with GNU General Public License v3.0 | 4 votes |
def remove(self, key, where=None, start=None, stop=None): """ Remove pandas object partially by specifying the where condition Parameters ---------- key : string Node to remove or delete rows from where : list of Term (or convertable) objects, optional start : integer (defaults to None), row number to start selection stop : integer (defaults to None), row number to stop selection Returns ------- number of rows removed (or None if not a Table) Exceptions ---------- raises KeyError if key is not a valid store """ where = _ensure_term(where, scope_level=1) try: s = self.get_storer(key) except: if where is not None: raise ValueError( "trying to remove a node with a non-None where clause!") # we are actually trying to remove a node (with children) s = self.get_node(key) if s is not None: s._f_remove(recursive=True) return None if s is None: raise KeyError('No object named %s in the file' % key) # remove the node if _all_none(where, start, stop): s.group._f_remove(recursive=True) # delete from the table else: if not s.is_table: raise ValueError( 'can only remove with where on objects written as tables') return s.delete(where=where, start=start, stop=stop)
Example #13
Source File: range.py From elasticintel with GNU General Public License v3.0 | 4 votes |
def __new__(cls, start=None, stop=None, step=None, name=None, dtype=None, fastpath=False, copy=False, **kwargs): if fastpath: return cls._simple_new(start, stop, step, name=name) cls._validate_dtype(dtype) # RangeIndex if isinstance(start, RangeIndex): if name is None: name = start.name return cls._simple_new(name=name, **dict(start._get_data_as_items())) # validate the arguments def _ensure_int(value, field): msg = ("RangeIndex(...) must be called with integers," " {value} was passed for {field}") if not is_scalar(value): raise TypeError(msg.format(value=type(value).__name__, field=field)) try: new_value = int(value) assert(new_value == value) except (TypeError, ValueError, AssertionError): raise TypeError(msg.format(value=type(value).__name__, field=field)) return new_value if _all_none(start, stop, step): msg = "RangeIndex(...) must be called with integers" raise TypeError(msg) elif start is None: start = 0 else: start = _ensure_int(start, 'start') if stop is None: stop = start start = 0 else: stop = _ensure_int(stop, 'stop') if step is None: step = 1 elif step == 0: raise ValueError("Step must not be zero") else: step = _ensure_int(step, 'step') return cls._simple_new(start, stop, step, name)
Example #14
Source File: pytables.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
def remove(self, key, where=None, start=None, stop=None): """ Remove pandas object partially by specifying the where condition Parameters ---------- key : string Node to remove or delete rows from where : list of Term (or convertable) objects, optional start : integer (defaults to None), row number to start selection stop : integer (defaults to None), row number to stop selection Returns ------- number of rows removed (or None if not a Table) Exceptions ---------- raises KeyError if key is not a valid store """ where = _ensure_term(where, scope_level=1) try: s = self.get_storer(key) except: if where is not None: raise ValueError( "trying to remove a node with a non-None where clause!") # we are actually trying to remove a node (with children) s = self.get_node(key) if s is not None: s._f_remove(recursive=True) return None if s is None: raise KeyError('No object named %s in the file' % key) # remove the node if _all_none(where, start, stop): s.group._f_remove(recursive=True) # delete from the table else: if not s.is_table: raise ValueError( 'can only remove with where on objects written as tables') return s.delete(where=where, start=start, stop=stop)
Example #15
Source File: range.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
def __new__(cls, start=None, stop=None, step=None, name=None, dtype=None, fastpath=False, copy=False, **kwargs): if fastpath: return cls._simple_new(start, stop, step, name=name) cls._validate_dtype(dtype) # RangeIndex if isinstance(start, RangeIndex): if name is None: name = start.name return cls._simple_new(name=name, **dict(start._get_data_as_items())) # validate the arguments def _ensure_int(value, field): msg = ("RangeIndex(...) must be called with integers," " {value} was passed for {field}") if not is_scalar(value): raise TypeError(msg.format(value=type(value).__name__, field=field)) try: new_value = int(value) assert(new_value == value) except (TypeError, ValueError, AssertionError): raise TypeError(msg.format(value=type(value).__name__, field=field)) return new_value if _all_none(start, stop, step): msg = "RangeIndex(...) must be called with integers" raise TypeError(msg) elif start is None: start = 0 else: start = _ensure_int(start, 'start') if stop is None: stop = start start = 0 else: stop = _ensure_int(stop, 'stop') if step is None: step = 1 elif step == 0: raise ValueError("Step must not be zero") else: step = _ensure_int(step, 'step') return cls._simple_new(start, stop, step, name)
Example #16
Source File: pytables.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def remove(self, key, where=None, start=None, stop=None): """ Remove pandas object partially by specifying the where condition Parameters ---------- key : string Node to remove or delete rows from where : list of Term (or convertible) objects, optional start : integer (defaults to None), row number to start selection stop : integer (defaults to None), row number to stop selection Returns ------- number of rows removed (or None if not a Table) Exceptions ---------- raises KeyError if key is not a valid store """ where = _ensure_term(where, scope_level=1) try: s = self.get_storer(key) except KeyError: # the key is not a valid store, re-raising KeyError raise except Exception: if where is not None: raise ValueError( "trying to remove a node with a non-None where clause!") # we are actually trying to remove a node (with children) s = self.get_node(key) if s is not None: s._f_remove(recursive=True) return None # remove the node if com._all_none(where, start, stop): s.group._f_remove(recursive=True) # delete from the table else: if not s.is_table: raise ValueError( 'can only remove with where on objects written as tables') return s.delete(where=where, start=start, stop=stop)
Example #17
Source File: panel.py From Computable with MIT License | 4 votes |
def reindex(self, major=None, items=None, minor=None, major_axis=None, minor_axis=None, copy=False): """ Conform / reshape panel axis labels to new input labels Parameters ---------- major : array-like, default None items : array-like, default None minor : array-like, default None copy : boolean, default False Copy underlying SparseDataFrame objects Returns ------- reindexed : SparsePanel """ major = com._mut_exclusive(major=major, major_axis=major_axis) minor = com._mut_exclusive(minor=minor, minor_axis=minor_axis) if com._all_none(items, major, minor): raise ValueError('Must specify at least one axis') major = self.major_axis if major is None else major minor = self.minor_axis if minor is None else minor if items is not None: new_frames = {} for item in items: if item in self._frames: new_frames[item] = self._frames[item] else: raise NotImplementedError('Reindexing with new items not yet ' 'supported') else: new_frames = self._frames if copy: new_frames = dict((k, v.copy()) for k, v in compat.iteritems(new_frames)) return SparsePanel(new_frames, items=items, major_axis=major, minor_axis=minor, default_fill_value=self.default_fill_value, default_kind=self.default_kind)
Example #18
Source File: pytables.py From vnpy_crypto with MIT License | 4 votes |
def remove(self, key, where=None, start=None, stop=None): """ Remove pandas object partially by specifying the where condition Parameters ---------- key : string Node to remove or delete rows from where : list of Term (or convertible) objects, optional start : integer (defaults to None), row number to start selection stop : integer (defaults to None), row number to stop selection Returns ------- number of rows removed (or None if not a Table) Exceptions ---------- raises KeyError if key is not a valid store """ where = _ensure_term(where, scope_level=1) try: s = self.get_storer(key) except KeyError: # the key is not a valid store, re-raising KeyError raise except Exception: if where is not None: raise ValueError( "trying to remove a node with a non-None where clause!") # we are actually trying to remove a node (with children) s = self.get_node(key) if s is not None: s._f_remove(recursive=True) return None # remove the node if com._all_none(where, start, stop): s.group._f_remove(recursive=True) # delete from the table else: if not s.is_table: raise ValueError( 'can only remove with where on objects written as tables') return s.delete(where=where, start=start, stop=stop)
Example #19
Source File: range.py From vnpy_crypto with MIT License | 4 votes |
def __new__(cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None, fastpath=False): if fastpath: return cls._simple_new(start, stop, step, name=name) cls._validate_dtype(dtype) # RangeIndex if isinstance(start, RangeIndex): if name is None: name = start.name return cls._simple_new(name=name, **dict(start._get_data_as_items())) # validate the arguments def _ensure_int(value, field): msg = ("RangeIndex(...) must be called with integers," " {value} was passed for {field}") if not is_scalar(value): raise TypeError(msg.format(value=type(value).__name__, field=field)) try: new_value = int(value) assert(new_value == value) except (TypeError, ValueError, AssertionError): raise TypeError(msg.format(value=type(value).__name__, field=field)) return new_value if com._all_none(start, stop, step): msg = "RangeIndex(...) must be called with integers" raise TypeError(msg) elif start is None: start = 0 else: start = _ensure_int(start, 'start') if stop is None: stop = start start = 0 else: stop = _ensure_int(stop, 'stop') if step is None: step = 1 elif step == 0: raise ValueError("Step must not be zero") else: step = _ensure_int(step, 'step') return cls._simple_new(start, stop, step, name)
Example #20
Source File: pytables.py From recruit with Apache License 2.0 | 4 votes |
def remove(self, key, where=None, start=None, stop=None): """ Remove pandas object partially by specifying the where condition Parameters ---------- key : string Node to remove or delete rows from where : list of Term (or convertible) objects, optional start : integer (defaults to None), row number to start selection stop : integer (defaults to None), row number to stop selection Returns ------- number of rows removed (or None if not a Table) Exceptions ---------- raises KeyError if key is not a valid store """ where = _ensure_term(where, scope_level=1) try: s = self.get_storer(key) except KeyError: # the key is not a valid store, re-raising KeyError raise except Exception: if where is not None: raise ValueError( "trying to remove a node with a non-None where clause!") # we are actually trying to remove a node (with children) s = self.get_node(key) if s is not None: s._f_remove(recursive=True) return None # remove the node if com._all_none(where, start, stop): s.group._f_remove(recursive=True) # delete from the table else: if not s.is_table: raise ValueError( 'can only remove with where on objects written as tables') return s.delete(where=where, start=start, stop=stop)
Example #21
Source File: range.py From recruit with Apache License 2.0 | 4 votes |
def __new__(cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None, fastpath=None): if fastpath is not None: warnings.warn("The 'fastpath' keyword is deprecated, and will be " "removed in a future version.", FutureWarning, stacklevel=2) if fastpath: return cls._simple_new(start, stop, step, name=name) cls._validate_dtype(dtype) # RangeIndex if isinstance(start, RangeIndex): if name is None: name = start.name return cls._simple_new(name=name, **dict(start._get_data_as_items())) # validate the arguments def ensure_int(value, field): msg = ("RangeIndex(...) must be called with integers," " {value} was passed for {field}") if not is_scalar(value): raise TypeError(msg.format(value=type(value).__name__, field=field)) try: new_value = int(value) assert(new_value == value) except (TypeError, ValueError, AssertionError): raise TypeError(msg.format(value=type(value).__name__, field=field)) return new_value if com._all_none(start, stop, step): msg = "RangeIndex(...) must be called with integers" raise TypeError(msg) elif start is None: start = 0 else: start = ensure_int(start, 'start') if stop is None: stop = start start = 0 else: stop = ensure_int(stop, 'stop') if step is None: step = 1 elif step == 0: raise ValueError("Step must not be zero") else: step = ensure_int(step, 'step') return cls._simple_new(start, stop, step, name)