This file contains 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 make_tooltipped_df(df, tooltips: dict): | |
""" | |
import pandas as pd | |
from IPython.display import display, HTML | |
# Sample DataFrame | |
data = {'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]} | |
df = pd.DataFrame(data) | |
# Apply styles to the DataFrame |
This file contains 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 joblib import Parallel, delayed | |
def expesive_calc(df): | |
df['new_col'] = ... | |
return df | |
def apply_parallel(gdf, func): | |
ret_list = Parallel(n_jobs=8)(delayed(func)(group) for name, group in gdf) | |
return pd.concat(ret_list) |
This file contains 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 sklearn.linear_model import LinearRegression | |
from sklearn.pipeline import FeatureUnion | |
from skits.feature_extraction import AutoregressiveTransformer | |
from skits.pipeline import ForecasterPipeline | |
from skits.preprocessing import ReversibleImputer | |
df = pd.DataFrame( | |
{ | |
"date": [1, 1, 1, 2, 2, 2, 3, 3 ,3, 4, 4, 4, 5, 5, 5], |
This file contains 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 joblib import Parallel, delayed | |
from sklearn import svm | |
data_train = [[0,2,3],[1,2,3],[4,2,3]] | |
targets_train = [0,1,0] | |
clf = svm.SVC(kernel='rbf', degree=3, C=10, gamma=0.3, probability=True) | |
clf.fit(data_train, targets_train) | |
to_be_predicted = np.array([[1,3,4], [1,3,4], [1,3,5]]) |