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
| git remote set-branches --add origin [remote-branch] | |
| git fetch origin [remote-branch]:[local-branch] |
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 to_ms(t, unit): | |
| """ | |
| @param t the time value | |
| @param unit can be 'ms', 's', 'min', 'h', 'd', 'm', 'y' | |
| namely for mili seconds, seconds, minutes, hours, days, months, years | |
| """ | |
| if unit == 'ms': | |
| return t | |
| elif unit == 's': |
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
| pd.set_option('display.max_rows', 500) | |
| pd.set_option('display.max_columns', 500) | |
| pd.set_option('display.width', 1000) |
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
| # Deux instances de 0 avec une target de chaque | |
| # Deux instances de 1 avec chacune une target à 0 | |
| # Deux instances de 2 avec chacune une target à 1 | |
| table = np.array([ | |
| [0, 0, 1], | |
| [1, 1, 0], | |
| [2, 1, 1] | |
| ]) | |
| table_df = pd.DataFrame(data=table[:, 1:], index=table[:, 0], columns=["target_0", "target_1"]) |
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
| # Deux instances de 0 avec une target de chaque | |
| # Deux instances de 1 avec chacune une target à 0 | |
| # Deux instances de 2 avec chacune une target à 1 | |
| table = np.array([ | |
| [0, 0], | |
| [0, 1], | |
| [1, 0], | |
| [1, 0], | |
| [2, 1], | |
| [2, 1] |
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
| df["nom_feature_categorielle"].value_counts() | |
| # exemple | |
| offers_df["proposal.FINANCIALSCALETYPE"].value_counts() | |
| """ | |
| STD 176486 | |
| WEB 69209 | |
| OPSPE 31862 | |
| DERO 15680 | |
| PCOL 23 |
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 PIL import Image | |
| img = Image.open("image.jpg") | |
| new_size = (50,50) | |
| img.resize(size=new_size, resample=Image.BILINEAR) | |
| img.save("image_new.jpg") |
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 time | |
| for i in range(5): | |
| print("\r{}".format(i), end="") | |
| time.sleep(1) |
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 re | |
| pattern = re.compile("c") | |
| bool(pattern.match("c")) # True | |
| bool(pattern.match("abcde")) # False | |
| bool(pattern.search("abcde")) # True |
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 json | |
| import requests # pip install requests | |
| from bravado_core.spec import Spec # pip install bravado_core | |
| # get openapi spec | |
| r = requests.get("https://dofapi2.herokuapp.com/openapi.json") | |
| # check response code | |
| if r.status_code != requests.codes.ok: | |
| print("Error : Website spec giver has responded with error code {}".format(r.status_code)) |
NewerOlder