This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reduce(lambda _, __: _ + __, valores) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections.abc import Mapping | |
| # Recursive function to apply a func to nested dict | |
| def map_nested_dicts(ob, func): | |
| if isinstance(ob, Mapping): | |
| return {key: map_nested_dicts(value, func) for key, value in ob.items()} | |
| return func(ob) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Specify a directory for plugins | |
| call plug#begin('~/.local/share/nvim/plugged') | |
| " Colorizer A plugin to color colornames and codes | |
| Plug 'chrisbra/Colorizer' | |
| " vim-markdown-composer An asynchronous markdown preview plugin for Vim and Neovim | |
| function! BuildComposer(info) | |
| if a:info.status != 'unchanged' || a:info.force | |
| if has('nvim') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def nan_if(data, missing_value): | |
| return np.where(data == missing_value, np.nan, data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [run] | |
| branch = True | |
| [report] | |
| exclude_lines= | |
| if response.status_code == 404: | |
| elif response.status_code == 503: | |
| pragma: no cover | |
| class ServiceUnavailable(Exception): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import facebook | |
| class SimpleFacebook(object): | |
| def __init__(self, oauth_token): | |
| self.graph = facebook.GraphAPI(oauth_token) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from controller import simple_facebook | |
| from unittest import mock, TestCase | |
| class SimpleFacebookTestCase(TestCase): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Aplicando formatos diferentes para cada coluna no DataFrame | |
| df = DataFrame({'a':[7.7885], 'b': [1.989878968657576e-10]}) | |
| # out | |
| # a b | |
| # 0 7.7885 1.989879e-10 | |
| df.loc[:, 'b'] = df.loc[:, 'b'].map(lambda x: float('%.11f' % x)) | |
| df.loc[:, 'a'] = df.loc[:, 'a'].map(lambda x: float('%.2f' % x)) | |
| # out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| data = np.random.rand(7, 3, 2) | |
| op_dict = {'sum': np.sum, 'mean': np.mean, 'max': np.max, 'min': np.min} | |
| def apply_function(func, data, step, axis=0, slice_=slice(None)): | |
| sections = np.arange(step, data.shape[axis], step) | |
| return np.array([func(d[slice_], axis=axis) for d in np.split(data, sections, axis=axis)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Para somar no eixo 1 de três em três | |
| txprec[::3].sum(axis=1) |