def _iter_formatted(self, max_items=9): ln = len(self) half_items = max_items // 2 if ln == 0: return elif ln < max_items: str_vec = StrVector(as_character(self)) else: str_vec = r_concat( as_character( self.rx(IntSexpVector(tuple(range(1, (half_items - 1)))))), StrSexpVector(['...']), as_character( self.rx(IntSexpVector(tuple(range((ln - half_items), ln)))))) for str_elt in str_vec: yield self.repr_format_elt(str_elt)
def _iter_formatted(self, max_items=9): format_elt = self.repr_format_elt l = len(self) half_items = max_items // 2 max_width = math.floor(52 / l) if l == 0: return elif l < max_items: str_vec = StrVector(as_character(self)) else: str_vec = r_concat( as_character( self.rx(IntSexpVector(tuple(range(1, (half_items - 1)))))), StrSexpVector(['...']), as_character( self.rx(IntSexpVector(tuple(range((l - half_items), l)))))) for str_elt in str_vec: yield self.repr_format_elt(str_elt)
def py2ri_categoryseries(obj): for c in obj.cat.categories: if not isinstance(c, str): raise ValueError('Converting pandas "Category" series to R factor is only possible when categories are strings.') res = IntSexpVector(list(x+1 for x in obj.cat.codes)) res.do_slot_assign('levels', StrSexpVector(obj.cat.categories)) if obj.cat.ordered: res.rclass = StrSexpVector('ordered', 'factor') else: res.rclass = StrSexpVector('factor') return res
def __init__(self, obj): obj = IntSexpVector(obj) super(IntVector, self).__init__(obj)
def tuple_str(tpl): res = IntSexpVector(tpl) return res