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 pytz import timezone | |
now_ist = datetime.now(tz=timezone("Asia/Kolkata")) | |
# set timezone | |
datetime_object.astimezone(timezone("Asia/Kolkata")) |
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 concurrent.futures | |
import multiprocessing | |
processing_thread_count =processing_thread_count = multiprocessing.cpu_count() -1 | |
with concurrent.futures.ThreadPoolExecutor(max_workers=processing_thread_count) as executor: | |
future_to_response = {executor.submit(function, arg1, arg2): i for i, msg in enumerate(a_list)} | |
for future in concurrent.futures.as_completed(future_to_response): | |
response = future_to_resonse[future] |
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 concurrent.futures | |
processing_thread_count = multiprocessing.cpu_count() - 1 | |
with concurrent.futures.ThreadPoolExecutor(max_workers=processing_thread_count) as executor: | |
future_to_response = {executor.submit(function, arg1, arg2): i for i, msg in enumerate(a_list)} | |
for future in concurrent.futures.as_completed(future_to_response): | |
response = future_to_resonse[future] | |
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 matplotlib.pyplot as plt | |
plt.plot(x, y, "o") | |
plt.plot(x, y_curve) | |
plt.show() | |
################# | |
def plot(x, y, title="Plot Title", xlabel='Xaxis', ylabel='Yaxis', dpi=100): | |
plt.figure(figsize=(16, 5), dpi=dpi) | |
plt.scatter(x, y, color='tab:red') |
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["time_stamp"].dt.floor('min') |
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
with open(file_path, 'r') as f: | |
token = f.readline() | |
with open(file_path, 'w', encoding='utf-8') as f: | |
f.write(string_to_write) |
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 pandas as pd | |
iter_csv = pd.read_csv('file.csv', iterator=True, chunksize=1000) | |
df = pd.concat([chunk[chunk['field'] > constant] for chunk in iter_csv]) |
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
headers = {'header-key': 'header-val'} | |
payload = {'key1':'val1', 'key2':'val2', 'key3':'val3'} | |
r = requests.post(endpoint, headers=headers, data=payload) |
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
ipython kernel install --user --name=venv |
NewerOlder