sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:to_json; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sets; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:set...
def to_json(self): sets = self.sets() return sorted(sorted(x) for x in sets)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:reload; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 20; 6, expression_statement; 6, 7; 7, string:'Generate histrow for each row and then reverse-sort by length.'; 8, expression_statement; 8, 9; 9, assignment; 9, 10;...
def reload(self): 'Generate histrow for each row and then reverse-sort by length.' self.rows = [] self.discreteBinning() for c in self.nonKeyVisibleCols: c._cachedValues = collections.OrderedDict()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resolve_colors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:colorstack; 6, block; 6, 7; 6, 9; 6, 15; 6, 37; 7, expression_statement; 7, 8; 8, string:'Returns the curses attribute for the colorstack, a list of color option names...
def resolve_colors(self, colorstack): 'Returns the curses attribute for the colorstack, a list of color option names sorted highest-precedence color first.' attr = CursesAttr() for coloropt in colorstack: c = self.get_color(coloropt) attr = attr.update_attr(c) ret...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_mentions; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:docs; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, False; 11, block; 11, 12; 11, 16; 11, 169; 12, express...
def get_mentions(self, docs=None, sort=False): result = [] if docs: docs = docs if isinstance(docs, (list, tuple)) else [docs] for mention_class in self.mention_classes: mentions = ( self.session.query(mention_class) .filter...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_candidates; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:docs; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:split; 10, integer:0; 11, default_parameter; 11, 12; 11...
def get_candidates(self, docs=None, split=0, sort=False): result = [] if docs: docs = docs if isinstance(docs, (list, tuple)) else [docs] for candidate_class in self.candidate_classes: cands = ( self.session.query(candidate_class) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:checked; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, block; 12, 13; 12, 29...
def add(self, text, checked=False, sort=None): node = ListItem(parent_id=self.id, parent_server_id=self.server_id) node.checked = checked node.text = text if sort is not None: node.sort = sort self.append(node, True) self.touch(True) return node
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:items_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:items; 6, block; 6, 7; 6, 148; 6, 188; 7, class_definition; 7, 8; 7, 9; 7, 11; 8, identifier:t; 9, argument_list; 9, 10; 10, identifier:tuple; 11, block; 11, 12; 11, 58; 11...
def items_sort(cls, items): class t(tuple): def __cmp__(self, other): for a, b in six.moves.zip_longest(self, other): if a != b: if a is None: return 1 if b is None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:checked; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, block; 12, 13; 12, 27...
def add(self, text, checked=False, sort=None): if self.parent is None: raise exception.InvalidException('Item has no parent') node = self.parent.add(text, checked, sort) self.indent(node) return node
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_subsections; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:srcdir; 5, identifier:examples_dir; 6, identifier:sortkey; 7, block; 7, 8; 7, 39; 7, 51; 7, 67; 7, 77; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:su...
def get_subsections(srcdir, examples_dir, sortkey): subfolders = [subfolder for subfolder in os.listdir(examples_dir) if os.path.exists(os.path.join( examples_dir, subfolder, 'README.txt'))] base_examples_dir_path = os.path.relpath(examples_dir, srcdir) subfolders_wit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:alphabetical_sort; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:list_to_sort; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterable; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:str; 12, ...
def alphabetical_sort(list_to_sort: Iterable[str]) -> List[str]: return sorted(list_to_sort, key=norm_fold)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:natural_sort; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:list_to_sort; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterable; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:str; 12, type;...
def natural_sort(list_to_sort: Iterable[str]) -> List[str]: return sorted(list_to_sort, key=natural_keys)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:_clauses; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 21; 9, 31; 9, 41; 9, 51; 9, 61; 9, 71; 9, 84; 9, 93; 9,...
def find(self, *_clauses, **kwargs): if not self.exists: return iter([]) _limit = kwargs.pop('_limit', None) _offset = kwargs.pop('_offset', 0) order_by = kwargs.pop('order_by', None) _streamed = kwargs.pop('_streamed', False) _step = kwargs.pop('_step', QUERY...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 6; 2, function_name:find_write_contribs; 3, parameters; 4, type; 4, 5; 5, None; 6, block; 6, 7; 6, 11; 6, 40; 6, 47; 6, 70; 6, 77; 6, 88; 6, 95; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:map_file_auth; 10, dictionary; 11, for_s...
def find_write_contribs() -> None: map_file_auth = {} for filename in scantree('cltk'): filepath = filename.path authors_list = get_authors(filepath) if authors_list: map_file_auth[filepath] = authors_list map_auth_file = defaultdict(list) for file, authors_file in ma...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_files; 3, parameters; 3, 4; 4, identifier:folder; 5, block; 5, 6; 5, 26; 5, 32; 5, 71; 5, 87; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:files; 9, list_comprehension; 9, 10; 9, 11; 9, 19; 10, identifier:i; 11, ...
def find_files(folder): files = [i for i in os.listdir(folder) if i.startswith("left")] files.sort() for i in range(len(files)): insert_string = "right{}".format(files[i * 2][4:]) files.insert(i * 2 + 1, insert_string) files = [os.path.join(folder, filename) for filename in files] re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:cdx_load; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sources; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:process; 8, True; 9, block; 9, 10; 9, 18; 9, 25; 9, 33; 9, 49; 9, 55; 9, 67; 9, 101; 10, expression_statement...
def cdx_load(sources, query, process=True): cdx_iter = create_merged_cdx_gen(sources, query) if query.page_count: return cdx_iter cdx_iter = make_obj_iter(cdx_iter, query) if process and not query.secondary_index_only: cdx_iter = process_cdx(cdx_iter, query) custom_ops = query.custom...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:cdx_sort_closest; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:closest; 5, identifier:cdx_iter; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:10; 9, block; 9, 10; 9, 14; 9, 18; 9, 25; 9, 104; 10, expression_statement; 10, ...
def cdx_sort_closest(closest, cdx_iter, limit=10): closest_cdx = [] closest_keys = [] closest_sec = timestamp_to_sec(closest) for cdx in cdx_iter: sec = timestamp_to_sec(cdx[TIMESTAMP]) key = abs(closest_sec - sec) i = bisect.bisect_right(closest_keys, key) closest_keys.i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:iter_prefix; 3, parameters; 3, 4; 3, 5; 4, identifier:reader; 5, identifier:key; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:itertools; 11, identifier:takewhile; 12, argument_list;...
def iter_prefix(reader, key): return itertools.takewhile( lambda line: line.startswith(key), search(reader, key))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_basis_dict; 3, parameters; 3, 4; 4, identifier:bs; 5, block; 5, 6; 5, 50; 5, 67; 5, 91; 5, 110; 5, 163; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:_keyorder; 9, list:[ 'molssi_bse_schema', 'schema_type'...
def sort_basis_dict(bs): _keyorder = [ 'molssi_bse_schema', 'schema_type', 'schema_version', 'jkfit', 'jfit', 'rifit', 'admmfit', 'dftxfit', 'dftjfit', 'name', 'names', 'aliases', 'flags', 'family', 'description', 'role', 'auxiliaries', 'notes', 'function_types', 'reference_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_shell; 3, parameters; 3, 4; 3, 5; 4, identifier:shell; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_copy; 7, True; 8, block; 8, 9; 8, 21; 8, 38; 8, 66; 8, 77; 8, 96; 8, 114; 8, 124; 8, 136; 8, 151; 8, 179; 8, 187; 8, 205; 8, 215; 8,...
def sort_shell(shell, use_copy=True): if use_copy: shell = copy.deepcopy(shell) tmp_c = list(map(list, zip(*shell['coefficients']))) nonzero_idx = [next((i for i, x in enumerate(c) if float(x) != 0.0), None) for c in tmp_c] tmp = zip(shell['exponents'], tmp_c, nonzero_idx) tmp = sorted(tmp, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_shells; 3, parameters; 3, 4; 3, 5; 4, identifier:shells; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_copy; 7, True; 8, block; 8, 9; 8, 21; 8, 33; 9, if_statement; 9, 10; 9, 11; 10, identifier:use_copy; 11, block; 11, 12; 12, expres...
def sort_shells(shells, use_copy=True): if use_copy: shells = copy.deepcopy(shells) shells = [sort_shell(sh, False) for sh in shells] return list( sorted( shells, key=lambda x: (max(x['angular_momentum']), -len(x['exponents']), -len(x['coefficients']), -float( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_potentials; 3, parameters; 3, 4; 3, 5; 4, identifier:potentials; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_copy; 7, True; 8, block; 8, 9; 8, 21; 8, 39; 8, 51; 9, if_statement; 9, 10; 9, 11; 10, identifier:use_copy; 11, block; 11,...
def sort_potentials(potentials, use_copy=True): if use_copy: potentials = copy.deepcopy(potentials) potentials = list(sorted(potentials, key=lambda x: x['angular_momentum'])) potentials.insert(0, potentials.pop()) return potentials
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_basis; 3, parameters; 3, 4; 3, 5; 4, identifier:basis; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_copy; 7, True; 8, block; 8, 9; 8, 21; 8, 67; 9, if_statement; 9, 10; 9, 11; 10, identifier:use_copy; 11, block; 11, 12; 12, expressi...
def sort_basis(basis, use_copy=True): if use_copy: basis = copy.deepcopy(basis) for k, el in basis['elements'].items(): if 'electron_shells' in el: el['electron_shells'] = sort_shells(el['electron_shells'], False) if 'ecp_potentials' in el: el['ecp_potentials'] = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_single_reference; 3, parameters; 3, 4; 4, identifier:ref_entry; 5, block; 5, 6; 5, 29; 5, 53; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:_keyorder; 9, list:[ 'schema_type', 'schema_version', 'ty...
def sort_single_reference(ref_entry): _keyorder = [ 'schema_type', 'schema_version', 'type', 'authors', 'title', 'booktitle', 'series', 'editors', 'journal', 'institution', 'volume', 'number', 'page', 'year', 'note', 'publisher', 'address', 'isbn', 'doi' ] sorted_entr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_references_dict; 3, parameters; 3, 4; 4, identifier:refs; 5, block; 5, 6; 5, 23; 5, 31; 5, 53; 6, if_statement; 6, 7; 6, 8; 6, 15; 7, identifier:_use_odict; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11...
def sort_references_dict(refs): if _use_odict: refs_sorted = OrderedDict() else: refs_sorted = dict() refs_sorted['molssi_bse_schema'] = refs['molssi_bse_schema'] for k, v in sorted(refs.items()): refs_sorted[k] = sort_single_reference(v) return refs_sorted
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:make_general; 3, parameters; 3, 4; 3, 5; 4, identifier:basis; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_copy; 7, True; 8, block; 8, 9; 8, 13; 8, 22; 8, 276; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifie...
def make_general(basis, use_copy=True): zero = '0.00000000' basis = uncontract_spdf(basis, 0, use_copy) for k, el in basis['elements'].items(): if not 'electron_shells' in el: continue all_am = [] for sh in el['electron_shells']: if not sh['angular_momentum'] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ComputeApplicationUniquifier; 3, parameters; 3, 4; 4, identifier:hash_obj; 5, block; 5, 6; 5, 144; 5, 193; 5, 259; 6, function_definition; 6, 7; 6, 8; 6, 14; 7, function_name:ProcessDirectory; 8, parameters; 8, 9; 8, 10; 8, 11; 9, identifier:pa...
def ComputeApplicationUniquifier(hash_obj): def ProcessDirectory(path, relative_path, depth=1): if depth > _MAX_DEPTH: return try: names = os.listdir(path) except BaseException: return modules = set() for name in sorted(names): current_path = os.path.join(path, name) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_set_player; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 114; 5, 141; 5, 152; 5, 158; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:players; 9, list:[]; 10, for_statement; 10, 11; 10, 14; 10, 21;...
def _set_player(self): players = [] for name, p in self._mpris_players.items(): if "_priority" not in p: if self.player_priority: try: priority = self.player_priority.index(p["name"]) except ValueError: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:file_sort; 3, parameters; 3, 4; 4, identifier:my_list; 5, block; 5, 6; 5, 33; 5, 42; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:alphanum_key; 8, parameters; 8, 9; 9, identifier:key; 10, block; 10, 11; 11, return_statement; 11, ...
def file_sort(my_list): def alphanum_key(key): return [int(s) if s.isdigit() else s for s in re.split("([0-9]+)", key)] my_list.sort(key=alphanum_key) return my_list
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:squad; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:R_in; 5, identifier:t_in; 6, identifier:t_out; 7, block; 7, 8; 7, 33; 7, 47; 7, 119; 7, 214; 7, 222; 7, 232; 7, 242; 7, 264; 7, 275; 7, 297; 7, 308; 7, 319; 7, 340; 7, 357; 7, 376; 8, if_sta...
def squad(R_in, t_in, t_out): if R_in.size == 0 or t_out.size == 0: return np.array((), dtype=np.quaternion) i_in_for_out = t_in.searchsorted(t_out, side='right')-1 A = R_in * np.exp((- np.log((~R_in) * np.roll(R_in, -1)) + np.log((~np.roll(R_in, 1)) * R_in) * ((np.roll(t_in, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_resource_id; 3, parameters; 3, 4; 3, 5; 4, identifier:prefix; 5, list_splat_pattern; 5, 6; 6, identifier:data; 7, block; 7, 8; 7, 15; 7, 43; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:parts; 11, call; 11, 12;...
def get_resource_id(prefix, *data): parts = flatten(data) for part in parts: if type(part) not in (str, int, float): raise ValueError('Supported data types: int, float, list, tuple, str. Got: {}'.format(type(part))) return '{}-{}'.format( prefix, get_hash('-'.join(sorted(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:iterator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:reverse; 11, False; 12, block; 12, 13; ...
def sorted(self, iterator, key=None, reverse=False): global MemoryBytesSpilled, DiskBytesSpilled batch, limit = 100, self._next_limit() chunks, current_chunk = [], [] iterator = iter(iterator) while True: chunk = list(itertools.islice(iterator, batch)) cur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_merge_sorted_items; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:index; 6, block; 6, 7; 6, 63; 6, 79; 6, 144; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:load_partition; 9, parameters; 9, 10; 10, identifier:j; 1...
def _merge_sorted_items(self, index): def load_partition(j): path = self._get_spill_dir(j) p = os.path.join(path, str(index)) with open(p, 'rb', 65536) as f: for v in self.serializer.load_stream(f): yield v disk_items = [load_partit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:map; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:f; 6, default_parameter; 6, 7; 6, 8; 7, identifier:preservesPartitioning; 8, False; 9, block; 9, 10; 9, 25; 10, function_definition; 10, 11; 10, 12; 10, 15; 11, function_na...
def map(self, f, preservesPartitioning=False): def func(_, iterator): return map(fail_on_stopiteration(f), iterator) return self.mapPartitionsWithIndex(func, preservesPartitioning)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:flatMap; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:f; 6, default_parameter; 6, 7; 6, 8; 7, identifier:preservesPartitioning; 8, False; 9, block; 9, 10; 9, 30; 10, function_definition; 10, 11; 10, 12; 10, 15; 11, functio...
def flatMap(self, f, preservesPartitioning=False): def func(s, iterator): return chain.from_iterable(map(fail_on_stopiteration(f), iterator)) return self.mapPartitionsWithIndex(func, preservesPartitioning)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:distinct; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:numPartitions; 7, None; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 36; 11, attribute; 11, 12; 11, 34; 11, 35; 12, ca...
def distinct(self, numPartitions=None): return self.map(lambda x: (x, None)) \ .reduceByKey(lambda x, _: x, numPartitions) \ .map(lambda x: x[0])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:repartitionAndSortWithinPartitions; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:numPartitions; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:partitionFunc; 10, ...
def repartitionAndSortWithinPartitions(self, numPartitions=None, partitionFunc=portable_hash, ascending=True, keyfunc=lambda x: x): if numPartitions is None: numPartitions = self._defaultReducePartitions() memory = _parse_memory(self.ctx._conf.get("...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sortBy; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:keyfunc; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ascending; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:numPartitions; 11, None; 12, block...
def sortBy(self, keyfunc, ascending=True, numPartitions=None): return self.keyBy(keyfunc).sortByKey(ascending, numPartitions).values()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:groupBy; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:f; 6, default_parameter; 6, 7; 6, 8; 7, identifier:numPartitions; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:partitionFunc; 11, identifier:porta...
def groupBy(self, f, numPartitions=None, partitionFunc=portable_hash): return self.map(lambda x: (f(x), x)).groupByKey(numPartitions, partitionFunc)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:top; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:num; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key; 8, None; 9, block; 9, 10; 9, 27; 9, 46; 10, function_definition; 10, 11; 10, 12; 10, 14; 11, function_name:topIter...
def top(self, num, key=None): def topIterator(iterator): yield heapq.nlargest(num, iterator, key=key) def merge(a, b): return heapq.nlargest(num, a + b, key=key) return self.mapPartitions(topIterator).reduce(merge)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:saveAsTextFile; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:compressionCodecClass; 8, None; 9, block; 9, 10; 9, 56; 9, 65; 9, 71; 10, function_definition; 10, 11; 10, ...
def saveAsTextFile(self, path, compressionCodecClass=None): def func(split, iterator): for x in iterator: if not isinstance(x, (unicode, bytes)): x = unicode(x) if isinstance(x, unicode): x = x.encode("utf-8") yi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:reduceByKey; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:numPartitions; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:partitionFunc; 11, identifie...
def reduceByKey(self, func, numPartitions=None, partitionFunc=portable_hash): return self.combineByKey(lambda x: x, func, func, numPartitions, partitionFunc)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:reduceByKeyLocally; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:func; 6, block; 6, 7; 6, 14; 6, 49; 6, 84; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:func; 10, call; 10, 11; 10, 12; 11, identifier:...
def reduceByKeyLocally(self, func): func = fail_on_stopiteration(func) def reducePartition(iterator): m = {} for k, v in iterator: m[k] = func(m[k], v) if k in m else v yield m def mergeMaps(m1, m2): for k, v in m2.items(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:combineByKey; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:createCombiner; 6, identifier:mergeValue; 7, identifier:mergeCombiners; 8, default_parameter; 8, 9; 8, 10; 9, identifier:numPartitions; 10, Non...
def combineByKey(self, createCombiner, mergeValue, mergeCombiners, numPartitions=None, partitionFunc=portable_hash): if numPartitions is None: numPartitions = self._defaultReducePartitions() serializer = self.ctx.serializer memory = self._memory_limit() a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:groupByKey; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:numPartitions; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:partitionFunc; 10, identifier:portable_hash; 11, block; 1...
def groupByKey(self, numPartitions=None, partitionFunc=portable_hash): def createCombiner(x): return [x] def mergeValue(xs, x): xs.append(x) return xs def mergeCombiners(a, b): a.extend(b) return a memory = self._memory_limit() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:lookup; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 27; 6, 54; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:values; 10, call; 10, 11; 10, 26; 11, attribute; 11, 12; 11, 25; 12...
def lookup(self, key): values = self.filter(lambda kv: kv[0] == key).values() if self.partitioner is not None: return self.ctx.runJob(values, lambda x: x, [self.partitioner(key)]) return values.collect()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:describeTopics; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:maxTermsPerTopic; 7, None; 8, block; 8, 9; 8, 35; 9, if_statement; 9, 10; 9, 13; 9, 23; 10, comparison_operator:is; 10, 11; 10, 12; 1...
def describeTopics(self, maxTermsPerTopic=None): if maxTermsPerTopic is None: topics = self.call("describeTopics") else: topics = self.call("describeTopics", maxTermsPerTopic) return topics
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_sort_cols; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:cols; 6, identifier:kwargs; 7, block; 7, 8; 7, 17; 7, 39; 7, 50; 7, 60; 7, 125; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:cols; 11, block;...
def _sort_cols(self, cols, kwargs): if not cols: raise ValueError("should sort by at least one column") if len(cols) == 1 and isinstance(cols[0], list): cols = cols[0] jcols = [_to_java_column(c) for c in cols] ascending = kwargs.get('ascending', True) if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_list_function_infos; 3, parameters; 3, 4; 4, identifier:jvm; 5, block; 5, 6; 5, 28; 5, 32; 5, 136; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:jinfos; 9, call; 9, 10; 9, 27; 10, attribute; 10, 11; 10, 26; 11, attrib...
def _list_function_infos(jvm): jinfos = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listBuiltinFunctionInfos() infos = [] for jinfo in jinfos: name = jinfo.getName() usage = jinfo.getUsage() usage = usage.replace("_FUNC_", name) if usage is not None else usage infos.ap...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:iterables; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 14; 11, 18; 11, 24; 11, ...
def merge(iterables, key=None, reverse=False): '''Merge multiple sorted inputs into a single sorted output. Similar to sorted(itertools.chain(*iterables)) but returns a generator, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to la...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:nsmallest; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:n; 5, identifier:iterable; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key; 8, None; 9, block; 9, 10; 9, 66; 9, 100; 9, 201; 9, 208; 9, 231; 9, 237; 9, 242; 9, 250; 9, 254; 9, 258; 9...
def nsmallest(n, iterable, key=None): if n == 1: it = iter(iterable) sentinel = object() if key is None: result = min(it, default=sentinel) else: result = min(it, default=sentinel, key=key) return [] if result is sentinel else [result] try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:nlargest; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:n; 5, identifier:iterable; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key; 8, None; 9, block; 9, 10; 9, 66; 9, 103; 9, 212; 9, 219; 9, 246; 9, 252; 9, 257; 9, 265; 9, 270; 9, 274; 9,...
def nlargest(n, iterable, key=None): if n == 1: it = iter(iterable) sentinel = object() if key is None: result = max(it, default=sentinel) else: result = max(it, default=sentinel, key=key) return [] if result is sentinel else [result] try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sortBy; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:col; 6, list_splat_pattern; 6, 7; 7, identifier:cols; 8, block; 8, 9; 8, 48; 8, 75; 8, 97; 9, if_statement; 9, 10; 9, 17; 10, call; 10, 11; 10, 12; 11, identifier:isinst...
def sortBy(self, col, *cols): if isinstance(col, (list, tuple)): if cols: raise ValueError("col is a {0} but cols are not empty".format(type(col))) col, cols = col[0], col[1:] if not all(isinstance(c, basestring) for c in cols) or not(isinstance(col, basestring)):...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:saveAsLibSVMFile; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:dir; 6, block; 6, 7; 6, 24; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:lines; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; ...
def saveAsLibSVMFile(data, dir): lines = data.map(lambda p: MLUtils._convert_labeled_point_to_libsvm(p)) lines.saveAsTextFile(dir)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:union; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:rdds; 6, block; 6, 7; 6, 15; 6, 40; 6, 58; 6, 73; 6, 94; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:first_jrdd_deserializer; 10, attribute; 10, 11...
def union(self, rdds): first_jrdd_deserializer = rdds[0]._jrdd_deserializer if any(x._jrdd_deserializer != first_jrdd_deserializer for x in rdds): rdds = [x._reserialize() for x in rdds] cls = SparkContext._jvm.org.apache.spark.api.java.JavaRDD jrdds = SparkContext._gateway.n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sortlevel; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:level; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 12; 11, 13;...
def sortlevel(self, level=None, ascending=True, sort_remaining=None): return self.sort_values(return_indexer=True, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_duplicates; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 20; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:warnings; 10, identifier:warn; 11, argument_list; 11, 12; 11, 16; 11, ...
def get_duplicates(self): warnings.warn("'get_duplicates' is deprecated and will be removed in " "a future release. You can use " "idx[idx.duplicated()].unique() instead", FutureWarning, stacklevel=2) return self[self.duplicated()].unique...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:union; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 17; 9, 24; 9, 31; 9, 53; 9, 68; 9, 108; 9, 133; 9, 158; 9, 319; 10, expression_s...
def union(self, other, sort=None): self._validate_sort_keyword(sort) self._assert_can_do_setop(other) other = ensure_index(other) if len(other) == 0 or self.equals(other): return self._get_reconciled_name_object(other) if len(self) == 0: return other._get_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:difference; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 17; 9, 24; 9, 45; 9, 56; 9, 64; 9, 73; 9, 92; 9, 112; 9, 123; 9, 143; 10, e...
def difference(self, other, sort=None): self._validate_sort_keyword(sort) self._assert_can_do_setop(other) if self.equals(other): return self._shallow_copy(self._data[:0]) other, result_name = self._convert_can_do_setop(other) this = self._get_unique_index() i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:symmetric_difference; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:result_name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, ...
def symmetric_difference(self, other, result_name=None, sort=None): self._validate_sort_keyword(sort) self._assert_can_do_setop(other) other, result_name_update = self._convert_can_do_setop(other) if result_name is None: result_name = result_name_update this = self._g...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:asof; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:label; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 21; 7, 28; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:loc; 12, call; 12, 13...
def asof(self, label): try: loc = self.get_loc(label, method='pad') except KeyError: return self._na_value else: if isinstance(loc, slice): loc = loc.indices(len(self))[-1] return self[loc]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_indexer; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 11, 20; 11, 34...
def sort_values(self, return_indexer=False, ascending=True): _as = self.argsort() if not ascending: _as = _as[::-1] sorted_index = self.take(_as) if return_indexer: return sorted_index, _as else: return sorted_index
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 16; 9, 30; 10, expression_statement; 10, 11; 11, assignm...
def argsort(self, *args, **kwargs): result = self.asi8 if result is None: result = np.array(self) return result.argsort(*args, **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:slice_indexer; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:end; 10, None; 11, default_parameter; 11, 12; 11...
def slice_indexer(self, start=None, end=None, step=None, kind=None): start_slice, end_slice = self.slice_locs(start, end, step=step, kind=kind) if not is_scalar(start_slice): raise AssertionError("Start slice bound is non-scalar") if n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_set_grouper; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:obj; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, False; 9, block; 9, 10; 9, 28; 9, 43; 9, 201; 9, 255; 9, 261; 9, 267; 10, if_statement; 10, 11; 10, 2...
def _set_grouper(self, obj, sort=False): if self.key is not None and self.level is not None: raise ValueError( "The Grouper cannot specify both a key and a level!") if self._grouper is None: self._grouper = self.grouper if self.key is not None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_from_derivatives; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:xi; 5, identifier:yi; 6, identifier:x; 7, default_parameter; 7, 8; 7, 9; 8, identifier:order; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:...
def _from_derivatives(xi, yi, x, order=None, der=0, extrapolate=False): from scipy import interpolate method = interpolate.BPoly.from_derivatives m = method(xi, yi.reshape(-1, 1), orders=order, extrapolate=extrapolate) return m(x)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:recode_for_groupby; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:c; 5, identifier:sort; 6, identifier:observed; 7, block; 7, 8; 7, 92; 7, 99; 7, 107; 7, 130; 8, if_statement; 8, 9; 8, 10; 9, identifier:observed; 10, block; 10, 11; 10, 20; 10,...
def recode_for_groupby(c, sort, observed): if observed: unique_codes = unique1d(c.codes) take_codes = unique_codes[unique_codes != -1] if c.ordered: take_codes = np.sort(take_codes) categories = c.categories.take(take_codes) codes = _recode_for_categories(c.codes,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:generate_bins_generic; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:values; 5, identifier:binner; 6, identifier:closed; 7, block; 7, 8; 7, 15; 7, 22; 7, 36; 7, 50; 7, 68; 7, 84; 7, 88; 7, 92; 7, 147; 8, expression_statement; 8, 9; 9, assignme...
def generate_bins_generic(values, binner, closed): lenidx = len(values) lenbin = len(binner) if lenidx <= 0 or lenbin <= 0: raise ValueError("Invalid length for values or for binner") if values[0] < binner[0]: raise ValueError("Values falls before first bin") if values[lenidx - 1] > ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:wide_to_long; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:df; 5, identifier:stubnames; 6, identifier:i; 7, identifier:j; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sep; 10, string:""; 11, default_parameter; 11, 12; ...
def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'): r def get_var_names(df, stub, sep, suffix): regex = r'^{stub}{sep}{suffix}$'.format( stub=re.escape(stub), sep=re.escape(sep), suffix=suffix) pattern = re.compile(regex) return [col for col in df.columns if pattern...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 18; 10, expression_statement; 10, 11; 11, call; 11, 12; ...
def argsort(self, *args, **kwargs): nv.validate_argsort(args, kwargs) if self._step > 0: return np.arange(len(self)) else: return np.arange(len(self) - 1, -1, -1)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:union; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 17; 9, 51; 9, 395; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 1...
def union(self, other, sort=None): self._assert_can_do_setop(other) if len(other) == 0 or self.equals(other) or len(self) == 0: return super().union(other, sort=sort) if isinstance(other, RangeIndex) and sort is None: start_s, step_s = self._start, self._step ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:nlargest; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:n; 6, identifier:columns; 7, default_parameter; 7, 8; 7, 9; 8, identifier:keep; 9, string:'first'; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12...
def nlargest(self, n, columns, keep='first'): return algorithms.SelectNFrame(self, n=n, keep=keep, columns=columns).nlargest()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:nsmallest; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:n; 6, identifier:columns; 7, default_parameter; 7, 8; 7, 9; 8, identifier:keep; 9, string:'first'; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 1...
def nsmallest(self, n, columns, keep='first'): return algorithms.SelectNFrame(self, n=n, keep=keep, columns=columns).nsmallest()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:append; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_index; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:verify_integrity; 11, Fal...
def append(self, other, ignore_index=False, verify_integrity=False, sort=None): if isinstance(other, (Series, dict)): if isinstance(other, dict): other = Series(other) if other.name is None and not ignore_index: raise TypeError('Can only app...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:join; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:on; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:how; 11, string:'left'; ...
def join(self, other, on=None, how='left', lsuffix='', rsuffix='', sort=False): return self._join_compat(other, on=on, how=how, lsuffix=lsuffix, rsuffix=rsuffix, sort=sort)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 9; 2, function_name:_values_for_argsort; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, attribute; 6, 7; 6, 8; 7, identifier:np; 8, identifier:ndarray; 9, block; 9, 10; 9, 20; 9, 34; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 1...
def _values_for_argsort(self) -> np.ndarray: data = self._data.copy() data[self._mask] = data.min() - 1 return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_get_combined_index; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:indexes; 5, default_parameter; 5, 6; 5, 7; 6, identifier:intersect; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, False; 11, block; 11, 12; 11, 19; 11, ...
def _get_combined_index(indexes, intersect=False, sort=False): indexes = _get_distinct_objs(indexes) if len(indexes) == 0: index = Index([]) elif len(indexes) == 1: index = indexes[0] elif intersect: index = indexes[0] for other in indexes[1:]: index = index.i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_union_indexes; 3, parameters; 3, 4; 3, 5; 4, identifier:indexes; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, True; 8, block; 8, 9; 8, 22; 8, 55; 8, 64; 8, 111; 9, if_statement; 9, 10; 9, 16; 10, comparison_operator:==; 10, 11; 10,...
def _union_indexes(indexes, sort=True): if len(indexes) == 0: raise AssertionError('Must have at least 1 Index to union') if len(indexes) == 1: result = indexes[0] if isinstance(result, list): result = Index(sorted(result)) return result indexes, kind = _sanitize_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sanitize_and_check; 3, parameters; 3, 4; 4, identifier:indexes; 5, block; 5, 6; 5, 20; 5, 70; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:kinds; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11, 12;...
def _sanitize_and_check(indexes): kinds = list({type(index) for index in indexes}) if list in kinds: if len(kinds) > 1: indexes = [Index(com.try_sort(x)) if not isinstance(x, Index) else x for x in indexes] kinds.remove(list) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_from_inferred_categories; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:cls; 5, identifier:inferred_categories; 6, identifier:inferred_codes; 7, identifier:dtype; 8, default_parameter; 8, 9; 8, 10; 9, identifier:true_values; 10, ...
def _from_inferred_categories(cls, inferred_categories, inferred_codes, dtype, true_values=None): from pandas import Index, to_numeric, to_datetime, to_timedelta cats = Index(inferred_categories) known_categories = (isinstance(dtype, CategoricalDtype) and ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:inplace; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 12; 11...
def sort_values(self, inplace=False, ascending=True, na_position='last'): inplace = validate_bool_kwarg(inplace, 'inplace') if na_position not in ['last', 'first']: msg = 'invalid na_position: {na_position!r}' raise ValueError(msg.format(na_position=na_position)) sorted_i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:unique; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 23; 5, 29; 5, 38; 5, 52; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:unique_codes; 9, call; 9, 10; 9, 11; 10, identifier:unique1d; 11, argume...
def unique(self): unique_codes = unique1d(self.codes) cat = self.copy() cat._codes = unique_codes take_codes = unique_codes[unique_codes != -1] if self.ordered: take_codes = np.sort(take_codes) return cat.set_categories(cat.categories.take(take_codes))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:concat; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:objs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:join; 10,...
def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True): op = _Concatenator(objs, axis=axis, join_axes=join_axes, ignore_index=ignore_index, join=join, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:cut; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:x; 5, identifier:bins; 6, default_parameter; 6, 7; 6, 8; 7, identifier:right; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:labels; 11, None; 1...
def cut(x, bins, right=True, labels=None, retbins=False, precision=3, include_lowest=False, duplicates='raise'): x_is_series, series_index, name, x = _preprocess_for_cut(x) x, dtype = _coerce_to_type(x) if not np.iterable(bins): if is_scalar(bins) and bins < 1: raise ValueError("...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:union_categoricals; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:to_union; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_categories; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ignore_order; 10, False; 11, block; 11, 12...
def union_categoricals(to_union, sort_categories=False, ignore_order=False): from pandas import Index, Categorical, CategoricalIndex, Series from pandas.core.arrays.categorical import _recode_for_categories if len(to_union) == 0: raise ValueError('No Categoricals to union') def _maybe_unwrap(x):...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 13; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:kind; 10, string:'quicksort'; 11, list_splat_patte...
def argsort(self, ascending=True, kind='quicksort', *args, **kwargs): ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs) values = self._values_for_argsort() result = np.argsort(values, kind=kind, **kwargs) if not ascending: result = result[::-1] r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 1, 21; 2, function_name:factorize; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:na_sentinel; 7, type; 7, 8; 8, identifier:int; 9, unary_operator:-; 9, 10; 10, integer:1; 11, type; 11, 12; 12, generi...
def factorize( self, na_sentinel: int = -1, ) -> Tuple[np.ndarray, ABCExtensionArray]: from pandas.core.algorithms import _factorize_array arr, na_value = self._values_for_factorize() labels, uniques = _factorize_array(arr, na_sentinel=na_sentinel, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_indexer; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, if_stateme...
def sort_values(self, return_indexer=False, ascending=True): if return_indexer: _as = self.argsort() if not ascending: _as = _as[::-1] sorted_index = self.take(_as) return sorted_index, _as else: sorted_values = np.sort(self._nd...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:axis; 10, integer:0; 11, default_parame...
def sort_values(self, by=None, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last'): raise NotImplementedError("sort_values has not been implemented " "on Panel or Panel4D objects.")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:groupby; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:axis; 10, integer:0; 1...
def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, squeeze=False, observed=False, **kwargs): from pandas.core.groupby.groupby import groupby if level is None and by is None: raise TypeError("You have to supply one of 'by' and 'level'") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parame...
def sort_values(self, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last'): inplace = validate_bool_kwarg(inplace, 'inplace') self._get_axis_number(axis) if inplace and self._is_cached: raise ValueError("This Series is a view of some other ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:sort_index; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:level; 10, None; 11, defau...
def sort_index(self, axis=0, level=None, ascending=True, inplace=False, kind='quicksort', na_position='last', sort_remaining=True): inplace = validate_bool_kwarg(inplace, 'inplace') self._get_axis_number(axis) index = self.index if level is not None: new_in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:nlargest; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:n; 7, integer:5; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keep; 10, string:'first'; 11, block; 11, 12; 12, return_statement;...
def nlargest(self, n=5, keep='first'): return algorithms.SelectNSeries(self, n=n, keep=keep).nlargest()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:nsmallest; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:n; 7, integer:5; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keep; 10, string:'first'; 11, block; 11, 12; 12, return_statement...
def nsmallest(self, n=5, keep='first'): return algorithms.SelectNSeries(self, n=n, keep=keep).nsmallest()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:searchsorted; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:value; 6, default_parameter; 6, 7; 6, 8; 7, identifier:side; 8, string:"left"; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sorter; 11, None; 12, bloc...
def searchsorted(self, value, side="left", sorter=None): try: value = self.dtype.type(value) except ValueError: pass return super().searchsorted(value, side=side, sorter=sorter)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:from_arrays; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:arrays; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sortorder; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:names; 11, None; 12, block; 12,...
def from_arrays(cls, arrays, sortorder=None, names=None): error_msg = "Input must be a list / sequence of array-likes." if not is_list_like(arrays): raise TypeError(error_msg) elif is_iterator(arrays): arrays = list(arrays) for array in arrays: if not ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:from_tuples; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:tuples; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sortorder; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:names; 11, None; 12, block; 12,...
def from_tuples(cls, tuples, sortorder=None, names=None): if not is_list_like(tuples): raise TypeError('Input must be a list / sequence of tuple-likes.') elif is_iterator(tuples): tuples = list(tuples) if len(tuples) == 0: if names is None: msg...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:from_product; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:iterables; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sortorder; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:names; 11, None; 12, block;...
def from_product(cls, iterables, sortorder=None, names=None): from pandas.core.arrays.categorical import _factorize_from_iterables from pandas.core.reshape.util import cartesian_product if not is_list_like(iterables): raise TypeError("Input must be a list / sequence of iterables.") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:from_frame; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:df; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sortorder; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:names; 11, None; 12, block; 12, 13; ...
def from_frame(cls, df, sortorder=None, names=None): if not isinstance(df, ABCDataFrame): raise TypeError("Input must be a DataFrame") column_names, columns = lzip(*df.iteritems()) names = column_names if names is None else names return cls.from_arrays(columns, sortorder=sort...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sortlevel; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:level; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 12; 11...
def sortlevel(self, level=0, ascending=True, sort_remaining=True): from pandas.core.sorting import indexer_from_factorized if isinstance(level, (str, int)): level = [level] level = [self._get_level_number(lev) for lev in level] sortorder = None if isinstance(ascending...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:slice_locs; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:end; 10, None; 11, default_parameter; 11, 12; 11, 1...
def slice_locs(self, start=None, end=None, step=None, kind=None): return super().slice_locs(start, end, step, kind=kind)