Timer unit: 1e-06 s Total time: 0.00022 s File: /usr/lib/python3.6/uuid.py Function: uuid1 at line 580 Line # Hits Time Per Hit % Time Line Contents ============================================================== 580 def uuid1(node=None, clock_seq=None): 581 """Generate a UUID from a host ID, sequence number, and the current time. 582 If 'node' is not given, getnode() is used to obtain the hardware 583 address. If 'clock_seq' is given, it is used as the sequence number; 584 otherwise a random 14-bit sequence number is chosen.""" 585 586 # When the system provides a version-1 UUID generator, use it (but don't 587 # use UuidCreate here because its UUIDs don't conform to RFC 4122). 588 1 3.0 3.0 1.4 if _uuid_generate_time and node is clock_seq is None: 589 1 57.0 57.0 25.9 _buffer = ctypes.create_string_buffer(16) 590 1 134.0 134.0 60.9 _uuid_generate_time(_buffer) 591 1 26.0 26.0 11.8 return UUID(bytes=bytes_(_buffer.raw)) 592 593 global _last_timestamp 594 import time 595 nanoseconds = int(time.time() * 1e9) 596 # 0x01b21dd213814000 is the number of 100-ns intervals between the 597 # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. 598 timestamp = int(nanoseconds/100) + 0x01b21dd213814000 599 if _last_timestamp is not None and timestamp <= _last_timestamp: 600 timestamp = _last_timestamp + 1 601 _last_timestamp = timestamp 602 if clock_seq is None: 603 import random 604 clock_seq = random.getrandbits(14) # instead of stable storage 605 time_low = timestamp & 0xffffffff 606 time_mid = (timestamp >> 32) & 0xffff 607 time_hi_version = (timestamp >> 48) & 0x0fff 608 clock_seq_low = clock_seq & 0xff 609 clock_seq_hi_variant = (clock_seq >> 8) & 0x3f 610 if node is None: 611 node = getnode() 612 return UUID(fields=(time_low, time_mid, time_hi_version, 613 clock_seq_hi_variant, clock_seq_low, node), version=1) Total time: 0.020274 s File: /usr/local/lib/python3.6/dist-packages/jinja2/environment.py Function: getattr at line 425 Line # Hits Time Per Hit % Time Line Contents ============================================================== 425 def getattr(self, obj, attribute): 426 """Get an item or attribute of an object but prefer the attribute. 427 Unlike :meth:`getitem` the attribute *must* be a bytestring. 428 """ 429 3901 2671.0 0.7 13.2 try: 430 3901 4857.0 1.2 24.0 return getattr(obj, attribute) 431 3901 2995.0 0.8 14.8 except AttributeError: 432 3901 2958.0 0.8 14.6 pass 433 3901 2654.0 0.7 13.1 try: 434 3901 2855.0 0.7 14.1 return obj[attribute] 435 408 401.0 1.0 2.0 except (TypeError, LookupError, AttributeError): 436 408 883.0 2.2 4.4 return self.undefined(obj=obj, name=attribute) Total time: 0.059669 s File: /usr/local/lib/python3.6/dist-packages/pandas/core/dtypes/inference.py Function: is_list_like at line 253 Line # Hits Time Per Hit % Time Line Contents ============================================================== 253 def is_list_like(obj, allow_sets=True): 254 """ 255 Check if the object is list-like. 256 257 Objects that are considered list-like are for example Python 258 lists, tuples, sets, NumPy arrays, and Pandas Series. 259 260 Strings and datetime objects, however, are not considered list-like. 261 262 Parameters 263 ---------- 264 obj : The object to check 265 allow_sets : boolean, default True 266 If this parameter is False, sets will not be considered list-like 267 268 .. versionadded:: 0.24.0 269 270 Returns 271 ------- 272 is_list_like : bool 273 Whether `obj` has list-like properties. 274 275 Examples 276 -------- 277 >>> is_list_like([1, 2, 3]) 278 True 279 >>> is_list_like({1, 2, 3}) 280 True 281 >>> is_list_like(datetime(2017, 1, 1)) 282 False 283 >>> is_list_like("foo") 284 False 285 >>> is_list_like(1) 286 False 287 >>> is_list_like(np.array([2])) 288 True 289 >>> is_list_like(np.array(2))) 290 False 291 """ 292 293 7671 36603.0 4.8 61.3 return (isinstance(obj, compat.Iterable) 294 # we do not count strings/unicode/bytes as list-like 295 7662 8966.0 1.2 15.0 and not isinstance(obj, string_and_binary_types) 296 297 # exclude zero-dimensional numpy arrays, effectively scalars 298 7662 8317.0 1.1 13.9 and not (isinstance(obj, np.ndarray) and obj.ndim == 0) 299 300 # exclude sets if allow_sets is False 301 7662 5783.0 0.8 9.7 and not (allow_sets is False and isinstance(obj, Set))) Total time: 4.9e-05 s File: /usr/local/lib/python3.6/dist-packages/pandas/core/dtypes/inference.py Function: is_dict_like at line 381 Line # Hits Time Per Hit % Time Line Contents ============================================================== 381 def is_dict_like(obj): 382 """ 383 Check if the object is dict-like. 384 385 Parameters 386 ---------- 387 obj : The object to check 388 389 Returns 390 ------- 391 is_dict_like : bool 392 Whether `obj` has dict-like properties. 393 394 Examples 395 -------- 396 >>> is_dict_like({1: 2}) 397 True 398 >>> is_dict_like([1, 2, 3]) 399 False 400 >>> is_dict_like(dict) 401 False 402 >>> is_dict_like(dict()) 403 True 404 """ 405 7 10.0 1.4 20.4 dict_like_attrs = ("__getitem__", "keys", "__contains__") 406 7 39.0 5.6 79.6 return (all(hasattr(obj, attr) for attr in dict_like_attrs) 407 # [GH 25196] exclude classes 408 and not isinstance(obj, type)) Total time: 5.3e-05 s File: /usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py Function: _non_reducing_slice at line 2724 Line # Hits Time Per Hit % Time Line Contents ============================================================== 2724 def _non_reducing_slice(slice_): 2725 """ 2726 Ensurse that a slice doesn't reduce to a Series or Scalar. 2727 2728 Any user-paseed `subset` should have this called on it 2729 to make sure we're always working with DataFrames. 2730 """ 2731 # default to column slice, like DataFrame 2732 # ['A', 'B'] -> IndexSlices[:, ['A', 'B']] 2733 1 3.0 3.0 5.7 kinds = tuple(list(compat.string_types) + [ABCSeries, np.ndarray, Index, 2734 1 2.0 2.0 3.8 list]) 2735 1 6.0 6.0 11.3 if isinstance(slice_, kinds): 2736 slice_ = IndexSlice[:, slice_] 2737 2738 1 1.0 1.0 1.9 def pred(part): 2739 # true when slice does *not* reduce, False when part is a tuple, 2740 # i.e. MultiIndex slice 2741 return ((isinstance(part, slice) or is_list_like(part)) 2742 and not isinstance(part, tuple)) 2743 2744 1 38.0 38.0 71.7 if not is_list_like(slice_): 2745 1 1.0 1.0 1.9 if not isinstance(slice_, slice): 2746 # a 1-d slice, like df.loc[1] 2747 slice_ = [[slice_]] 2748 else: 2749 # slice(a, b, c) 2750 1 1.0 1.0 1.9 slice_ = [slice_] # to tuplize later 2751 else: 2752 slice_ = [part if pred(part) else [part] for part in slice_] 2753 1 1.0 1.0 1.9 return tuple(slice_) Total time: 7.6e-05 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: __init__ at line 122 Line # Hits Time Per Hit % Time Line Contents ============================================================== 122 def __init__(self, data, precision=None, table_styles=None, uuid=None, 123 caption=None, table_attributes=None, cell_ids=True): 124 1 5.0 5.0 6.6 self.ctx = defaultdict(list) 125 1 2.0 2.0 2.6 self._todo = [] 126 127 1 3.0 3.0 3.9 if not isinstance(data, (pd.Series, pd.DataFrame)): 128 raise TypeError("``data`` must be a Series or DataFrame") 129 1 7.0 7.0 9.2 if data.ndim == 1: 130 data = data.to_frame() 131 1 8.0 8.0 10.5 if not data.index.is_unique or not data.columns.is_unique: 132 raise ValueError("style is not supported for non-unique indices.") 133 134 1 2.0 2.0 2.6 self.data = data 135 1 2.0 2.0 2.6 self.index = data.index 136 1 1.0 1.0 1.3 self.columns = data.columns 137 138 1 1.0 1.0 1.3 self.uuid = uuid 139 1 2.0 2.0 2.6 self.table_styles = table_styles 140 1 1.0 1.0 1.3 self.caption = caption 141 1 2.0 2.0 2.6 if precision is None: 142 1 29.0 29.0 38.2 precision = get_option('display.precision') 143 1 2.0 2.0 2.6 self.precision = precision 144 1 1.0 1.0 1.3 self.table_attributes = table_attributes 145 1 1.0 1.0 1.3 self.hidden_index = False 146 1 1.0 1.0 1.3 self.hidden_columns = [] 147 1 2.0 2.0 2.6 self.cell_ids = cell_ids 148 149 # display_funcs maps (row, col) -> formatting function 150 151 1 2.0 2.0 2.6 def default_display_func(x): 152 if is_float(x): 153 return '{:>.{precision}g}'.format(x, precision=self.precision) 154 else: 155 return x 156 157 1 2.0 2.0 2.6 self._display_funcs = defaultdict(lambda: default_display_func) Total time: 0.048713 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _translate at line 189 Line # Hits Time Per Hit % Time Line Contents ============================================================== 189 def _translate(self): 190 """ 191 Convert the DataFrame in `self.data` and the attrs from `_build_styles` 192 into a dictionary of {head, body, uuid, cellstyle}. 193 """ 194 1 3.0 3.0 0.0 table_styles = self.table_styles or [] 195 1 3.0 3.0 0.0 caption = self.caption 196 1 3.0 3.0 0.0 ctx = self.ctx 197 1 3.0 3.0 0.0 precision = self.precision 198 1 3.0 3.0 0.0 hidden_index = self.hidden_index 199 1 2.0 2.0 0.0 hidden_columns = self.hidden_columns 200 1 248.0 248.0 0.5 uuid = self.uuid or str(uuid1()).replace("-", "_") 201 1 3.0 3.0 0.0 ROW_HEADING_CLASS = "row_heading" 202 1 2.0 2.0 0.0 COL_HEADING_CLASS = "col_heading" 203 1 3.0 3.0 0.0 INDEX_NAME_CLASS = "index_name" 204 205 1 2.0 2.0 0.0 DATA_CLASS = "data" 206 1 2.0 2.0 0.0 BLANK_CLASS = "blank" 207 1 2.0 2.0 0.0 BLANK_VALUE = "" 208 209 1 3.0 3.0 0.0 def format_attr(pair): 210 return "{key}={value}".format(**pair) 211 212 # for sparsifying a MultiIndex 213 1 5878.0 5878.0 12.1 idx_lengths = _get_level_lengths(self.index) 214 1 309.0 309.0 0.6 col_lengths = _get_level_lengths(self.columns, hidden_columns) 215 216 1 4.0 4.0 0.0 cell_context = dict() 217 218 1 7.0 7.0 0.0 n_rlvls = self.data.index.nlevels 219 1 4.0 4.0 0.0 n_clvls = self.data.columns.nlevels 220 1 48.0 48.0 0.1 rlabels = self.data.index.tolist() 221 1 34.0 34.0 0.1 clabels = self.data.columns.tolist() 222 223 1 2.0 2.0 0.0 if n_rlvls == 1: 224 rlabels = [[x] for x in rlabels] 225 1 3.0 3.0 0.0 if n_clvls == 1: 226 1 5.0 5.0 0.0 clabels = [[x] for x in clabels] 227 1 5.0 5.0 0.0 clabels = list(zip(*clabels)) 228 229 1 3.0 3.0 0.0 cellstyle = [] 230 1 3.0 3.0 0.0 head = [] 231 232 2 7.0 3.5 0.0 for r in range(n_clvls): 233 # Blank for Index columns... 234 1 2.0 2.0 0.0 row_es = [{"type": "th", 235 1 3.0 3.0 0.0 "value": BLANK_VALUE, 236 1 3.0 3.0 0.0 "display_value": BLANK_VALUE, 237 1 3.0 3.0 0.0 "is_visible": not hidden_index, 238 1 5.0 5.0 0.0 "class": " ".join([BLANK_CLASS])}] * (n_rlvls - 1) 239 240 # ... except maybe the last for columns.names 241 1 11.0 11.0 0.0 name = self.data.columns.names[r] 242 1 2.0 2.0 0.0 cs = [BLANK_CLASS if name is None else INDEX_NAME_CLASS, 243 1 5.0 5.0 0.0 "level{lvl}".format(lvl=r)] 244 1 3.0 3.0 0.0 name = BLANK_VALUE if name is None else name 245 1 3.0 3.0 0.0 row_es.append({"type": "th", 246 1 2.0 2.0 0.0 "value": name, 247 1 3.0 3.0 0.0 "display_value": name, 248 1 3.0 3.0 0.0 "class": " ".join(cs), 249 1 3.0 3.0 0.0 "is_visible": not hidden_index}) 250 251 1 3.0 3.0 0.0 if clabels: 252 5 15.0 3.0 0.0 for c, value in enumerate(clabels[r]): 253 4 14.0 3.5 0.0 cs = [COL_HEADING_CLASS, "level{lvl}".format(lvl=r), 254 4 13.0 3.2 0.0 "col{col}".format(col=c)] 255 4 12.0 3.0 0.0 cs.extend(cell_context.get( 256 4 14.0 3.5 0.0 "col_headings", {}).get(r, {}).get(c, [])) 257 es = { 258 4 11.0 2.8 0.0 "type": "th", 259 4 11.0 2.8 0.0 "value": value, 260 4 11.0 2.8 0.0 "display_value": value, 261 4 11.0 2.8 0.0 "class": " ".join(cs), 262 4 24.0 6.0 0.0 "is_visible": _is_visible(c, r, col_lengths), 263 } 264 4 12.0 3.0 0.0 colspan = col_lengths.get((r, c), 0) 265 4 10.0 2.5 0.0 if colspan > 1: 266 es["attributes"] = [ 267 format_attr({"key": "colspan", "value": colspan}) 268 ] 269 4 11.0 2.8 0.0 row_es.append(es) 270 1 3.0 3.0 0.0 head.append(row_es) 271 272 1 9.0 9.0 0.0 if (self.data.index.names and 273 1 10.0 10.0 0.0 com._any_not_none(*self.data.index.names) and 274 1 3.0 3.0 0.0 not hidden_index): 275 1 3.0 3.0 0.0 index_header_row = [] 276 277 3 13.0 4.3 0.0 for c, name in enumerate(self.data.index.names): 278 2 6.0 3.0 0.0 cs = [INDEX_NAME_CLASS, 279 2 7.0 3.5 0.0 "level{lvl}".format(lvl=c)] 280 2 6.0 3.0 0.0 name = '' if name is None else name 281 2 6.0 3.0 0.0 index_header_row.append({"type": "th", "value": name, 282 2 6.0 3.0 0.0 "class": " ".join(cs)}) 283 284 1 3.0 3.0 0.0 index_header_row.extend( 285 1 3.0 3.0 0.0 [{"type": "th", 286 1 2.0 2.0 0.0 "value": BLANK_VALUE, 287 1 4.0 4.0 0.0 "class": " ".join([BLANK_CLASS]) 288 1 4.0 4.0 0.0 }] * (len(clabels[0]) - len(hidden_columns))) 289 290 1 3.0 3.0 0.0 head.append(index_header_row) 291 292 1 2.0 2.0 0.0 body = [] 293 79 274.0 3.5 0.6 for r, idx in enumerate(self.data.index): 294 78 219.0 2.8 0.4 row_es = [] 295 234 681.0 2.9 1.4 for c, value in enumerate(rlabels[r]): 296 156 497.0 3.2 1.0 rid = [ROW_HEADING_CLASS, "level{lvl}".format(lvl=c), 297 156 501.0 3.2 1.0 "row{row}".format(row=r)] 298 es = { 299 156 394.0 2.5 0.8 "type": "th", 300 156 860.0 5.5 1.8 "is_visible": (_is_visible(r, c, idx_lengths) and 301 79 213.0 2.7 0.4 not hidden_index), 302 156 385.0 2.5 0.8 "value": value, 303 156 395.0 2.5 0.8 "display_value": value, 304 156 453.0 2.9 0.9 "id": "_".join(rid[1:]), 305 156 512.0 3.3 1.1 "class": " ".join(rid) 306 } 307 156 454.0 2.9 0.9 rowspan = idx_lengths.get((c, r), 0) 308 156 417.0 2.7 0.9 if rowspan > 1: 309 es["attributes"] = [ 310 1 6.0 6.0 0.0 format_attr({"key": "rowspan", "value": rowspan}) 311 ] 312 156 411.0 2.6 0.8 row_es.append(es) 313 314 390 3905.0 10.0 8.0 for c, col in enumerate(self.data.columns): 315 312 999.0 3.2 2.1 cs = [DATA_CLASS, "row{row}".format(row=r), 316 312 983.0 3.2 2.0 "col{col}".format(col=c)] 317 312 1128.0 3.6 2.3 cs.extend(cell_context.get("data", {}).get(r, {}).get(c, [])) 318 312 1159.0 3.7 2.4 formatter = self._display_funcs[(r, c)] 319 312 11310.0 36.2 23.2 value = self.data.iloc[r, c] 320 312 850.0 2.7 1.7 row_dict = {"type": "td", 321 312 813.0 2.6 1.7 "value": value, 322 312 915.0 2.9 1.9 "class": " ".join(cs), 323 312 1075.0 3.4 2.2 "display_value": formatter(value), 324 312 909.0 2.9 1.9 "is_visible": (c not in hidden_columns)} 325 # only add an id if the cell has a style 326 312 855.0 2.7 1.8 if (self.cell_ids or 327 not(len(ctx[r, c]) == 1 and ctx[r, c][0] == '')): 328 312 1110.0 3.6 2.3 row_dict["id"] = "_".join(cs[1:]) 329 312 863.0 2.8 1.8 row_es.append(row_dict) 330 312 833.0 2.7 1.7 props = [] 331 624 2211.0 3.5 4.5 for x in ctx[r, c]: 332 # have to handle empty styles like [''] 333 312 964.0 3.1 2.0 if x.count(":"): 334 312 1120.0 3.6 2.3 props.append(x.split(":")) 335 else: 336 props.append(['', '']) 337 312 829.0 2.7 1.7 cellstyle.append({'props': props, 338 312 797.0 2.6 1.6 'selector': "row{row}_col{col}" 339 312 1252.0 4.0 2.6 .format(row=r, col=c)}) 340 78 207.0 2.7 0.4 body.append(row_es) 341 342 1 3.0 3.0 0.0 table_attr = self.table_attributes 343 1 28.0 28.0 0.1 use_mathjax = get_option("display.html.use_mathjax") 344 1 2.0 2.0 0.0 if not use_mathjax: 345 table_attr = table_attr or '' 346 if 'class="' in table_attr: 347 table_attr = table_attr.replace('class="', 348 'class="tex2jax_ignore ') 349 else: 350 table_attr += ' class="tex2jax_ignore"' 351 352 1 3.0 3.0 0.0 return dict(head=head, cellstyle=cellstyle, body=body, uuid=uuid, 353 1 3.0 3.0 0.0 precision=precision, table_styles=table_styles, 354 1 5.0 5.0 0.0 caption=caption, table_attributes=table_attr) Total time: 1.69619 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: render at line 421 Line # Hits Time Per Hit % Time Line Contents ============================================================== 421 def render(self, **kwargs): 422 """ 423 Render the built up styles to HTML. 424 425 Parameters 426 ---------- 427 `**kwargs` : Any additional keyword arguments are passed through 428 to ``self.template.render``. This is useful when you need to provide 429 additional variables for a custom template. 430 431 .. versionadded:: 0.20 432 433 Returns 434 ------- 435 rendered : str 436 the rendered HTML 437 438 Notes 439 ----- 440 ``Styler`` objects have defined the ``_repr_html_`` method 441 which automatically calls ``self.render()`` when it's the 442 last item in a Notebook cell. When calling ``Styler.render()`` 443 directly, wrap the result in ``IPython.display.HTML`` to view 444 the rendered HTML in the notebook. 445 446 Pandas uses the following keys in render. Arguments passed 447 in ``**kwargs`` take precedence, so think carefully if you want 448 to override them: 449 450 * head 451 * cellstyle 452 * body 453 * uuid 454 * precision 455 * table_styles 456 * caption 457 * table_attributes 458 """ 459 1 1563848.0 1563848.0 92.2 self._compute() 460 # TODO: namespace all the pandas keys 461 1 79122.0 79122.0 4.7 d = self._translate() 462 # filter out empty styles, every cell will have a class 463 # but the list of props may just be [['', '']]. 464 # so we have the neested anys below 465 1 411.0 411.0 0.0 trimmed = [x for x in d['cellstyle'] 466 if any(any(y) for y in x['props'])] 467 1 2.0 2.0 0.0 d['cellstyle'] = trimmed 468 1 1.0 1.0 0.0 d.update(kwargs) 469 1 52803.0 52803.0 3.1 return self.template.render(**d) Total time: 1.5547 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _update_ctx at line 471 Line # Hits Time Per Hit % Time Line Contents ============================================================== 471 def _update_ctx(self, attrs): 472 """ 473 Update the state of the Styler. 474 475 Collects a mapping of {index_label: [': ']}. 476 477 attrs : Series or DataFrame 478 should contain strings of ': ;: ' 479 Whitespace shouldn't matter and the final trailing ';' shouldn't 480 matter. 481 """ 482 79 23363.0 295.7 1.5 for row_label, v in attrs.iterrows(): 483 390 6213.0 15.9 0.4 for col_label, col in v.iteritems(): 484 312 1351736.0 4332.5 86.9 i = self.index.get_indexer([row_label])[0] 485 312 170846.0 547.6 11.0 j = self.columns.get_indexer([col_label])[0] 486 624 1466.0 2.3 0.1 for pair in col.rstrip(";").split(";"): 487 312 1079.0 3.5 0.1 self.ctx[(i, j)].append(pair) Total time: 1.56384 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _compute at line 518 Line # Hits Time Per Hit % Time Line Contents ============================================================== 518 def _compute(self): 519 """ 520 Execute the style functions built up in `self._todo`. 521 522 Relies on the conventions that all style functions go through 523 .apply or .applymap. The append styles to apply as tuples of 524 525 (application method, *args, **kwargs) 526 """ 527 1 0.0 0.0 0.0 r = self 528 2 2.0 1.0 0.0 for func, args, kwargs in self._todo: 529 1 1563835.0 1563835.0 100.0 r = func(self)(*args, **kwargs) 530 1 1.0 1.0 0.0 return r Total time: 1.56381 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _applymap at line 614 Line # Hits Time Per Hit % Time Line Contents ============================================================== 614 def _applymap(self, func, subset=None, **kwargs): 615 1 2.0 2.0 0.0 func = partial(func, **kwargs) # applymap doesn't take kwargs? 616 1 1.0 1.0 0.0 if subset is None: 617 1 4.0 4.0 0.0 subset = pd.IndexSlice[:] 618 1 70.0 70.0 0.0 subset = _non_reducing_slice(subset) 619 1 6571.0 6571.0 0.4 result = self.data.loc[subset].applymap(func) 620 1 1557166.0 1557166.0 99.6 self._update_ctx(result) 621 1 1.0 1.0 0.0 return self Total time: 2e-06 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: applymap at line 623 Line # Hits Time Per Hit % Time Line Contents ============================================================== 623 def applymap(self, func, subset=None, **kwargs): 624 """ 625 Apply a function elementwise, updating the HTML 626 representation with the result. 627 628 Parameters 629 ---------- 630 func : function 631 ``func`` should take a scalar and return a scalar 632 subset : IndexSlice 633 a valid indexer to limit ``data`` to *before* applying the 634 function. Consider using a pandas.IndexSlice 635 kwargs : dict 636 pass along to ``func`` 637 638 Returns 639 ------- 640 self : Styler 641 642 See Also 643 -------- 644 Styler.where 645 """ 646 1 1.0 1.0 50.0 self._todo.append((lambda instance: getattr(instance, '_applymap'), 647 1 1.0 1.0 50.0 (func, subset), kwargs)) 648 1 0.0 0.0 0.0 return self Total time: 1.8e-05 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: set_properties at line 987 Line # Hits Time Per Hit % Time Line Contents ============================================================== 987 def set_properties(self, subset=None, **kwargs): 988 """ 989 Convenience method for setting one or more non-data dependent 990 properties or each cell. 991 992 Parameters 993 ---------- 994 subset : IndexSlice 995 a valid slice for ``data`` to limit the style application to 996 kwargs : dict 997 property: value pairs to be set for each cell 998 999 Returns 1000 ------- 1001 self : Styler 1002 1003 Examples 1004 -------- 1005 >>> df = pd.DataFrame(np.random.randn(10, 4)) 1006 >>> df.style.set_properties(color="white", align="right") 1007 >>> df.style.set_properties(**{'background-color': 'yellow'}) 1008 """ 1009 1 1.0 1.0 5.6 values = ';'.join('{p}: {v}'.format(p=p, v=v) 1010 1 7.0 7.0 38.9 for p, v in kwargs.items()) 1011 1 1.0 1.0 5.6 f = lambda x: values 1012 1 9.0 9.0 50.0 return self.applymap(f, subset=subset) Total time: 0.000165 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _is_visible at line 1309 Line # Hits Time Per Hit % Time Line Contents ============================================================== 1309 def _is_visible(idx_row, idx_col, lengths): 1310 """ 1311 Index -> {(idx_row, idx_col): bool}). 1312 """ 1313 160 165.0 1.0 100.0 return (idx_col, idx_row) in lengths Total time: 0.005283 s File: /usr/local/lib/python3.6/dist-packages/pandas/io/formats/style.py Function: _get_level_lengths at line 1316 Line # Hits Time Per Hit % Time Line Contents ============================================================== 1316 def _get_level_lengths(index, hidden_elements=None): 1317 """ 1318 Given an index, find the level length for each element. 1319 1320 Optional argument is a list of index positions which 1321 should not be visible. 1322 1323 Result is a dictionary of (level, inital_position): span 1324 """ 1325 2 58.0 29.0 1.1 sentinel = com.sentinel_factory() 1326 2 2835.0 1417.5 53.7 levels = index.format(sparsify=sentinel, adjoin=False, names=False) 1327 1328 2 4.0 2.0 0.1 if hidden_elements is None: 1329 1 2.0 2.0 0.0 hidden_elements = [] 1330 1331 2 3.0 1.5 0.1 lengths = {} 1332 2 5.0 2.5 0.1 if index.nlevels == 1: 1333 5 7.0 1.4 0.1 for i, value in enumerate(levels): 1334 4 4.0 1.0 0.1 if(i not in hidden_elements): 1335 4 6.0 1.5 0.1 lengths[(0, i)] = 1 1336 1 1.0 1.0 0.0 return lengths 1337 1338 3 3.0 1.0 0.1 for i, lvl in enumerate(levels): 1339 158 159.0 1.0 3.0 for j, row in enumerate(lvl): 1340 156 1586.0 10.2 30.0 if not get_option('display.multi_sparse'): 1341 lengths[(i, j)] = 1 1342 156 160.0 1.0 3.0 elif (row != sentinel) and (j not in hidden_elements): 1343 79 73.0 0.9 1.4 last_label = j 1344 79 117.0 1.5 2.2 lengths[(i, last_label)] = 1 1345 77 72.0 0.9 1.4 elif (row != sentinel): 1346 # even if its hidden, keep track of it in case 1347 # length >1 and later elements are visible 1348 last_label = j 1349 lengths[(i, last_label)] = 0 1350 77 76.0 1.0 1.4 elif(j not in hidden_elements): 1351 77 83.0 1.1 1.6 lengths[(i, last_label)] += 1 1352 1353 1 2.0 2.0 0.0 non_zero_lengths = { 1354 1 27.0 27.0 0.5 element: length for element, length in lengths.items() if length >= 1} 1355 1356 1 0.0 0.0 0.0 return non_zero_lengths