def test__nbrows(): df = pd.DataFrame({ "a": np.arange(10), "b": ["aa", "bb", "cc"] * 3 + ["dd"] }) assert _nbrows(df) == 10 assert _nbrows(df.values) == 10 assert _nbrows(df["a"]) == 10 assert _nbrows(df["a"].values) == 10
def _verif(self): if not isinstance(self.all_datas, (list, dict)): raise TypeError( "I don't know how to handle that type of Data : %s" % type(self.all_datas)) if hasattr(self.all_datas, "items"): nbrows = [_nbrows(data) for key, data in self.all_datas.items()] nbcols = [_nbcols(data) for key, data in self.all_datas.items()] self._is_dict = True else: nbrows = [_nbrows(data) for data in self.all_datas] nbcols = [_nbcols(data) for data in self.all_datas] self._is_dict = False if len(set(nbrows)) > 1: raise ValueError("All objects don't have the same length") self._nbrows = nbrows[0] self._nbcols = sum(nbcols)