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
df.to_excel('test.xlsx', sheet_name='sheet1', index=False) |
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
fullDf['forecast_date'].fillna(fullDf.day, inplace=True) |
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
calls_final.calls_tw=calls_final.calls_tw.map(lambda x: x if np.isfinite(x) else 0) |
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
visits_wd['label_time']=visits_wd['last_date'].map(lambda x: x-relativedelta(months=goback)) | |
df_test1['add']=pd.to_timedelta(df_test1['add'], unit='D')# convert integers to days this way | |
df_test1['forecast_date']=df_test1['forweek']+df_test1['add'] |
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
df['date'].dt.weekday_name |
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
df.sort_index(inplace=True) ####will so the df by index in place |
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 datetime import date | |
def sun_date(input): | |
d = input.toordinal() | |
last = d | |
sunday = last - (last % 7) | |
return date.fromordinal(sunday) | |
# converting to ordunal help calculations |
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
Today = datetime.now() | |
Today | |
##############datetime.datetime(2017, 7, 17, 17, 54, 32, 101687) | |
import pytz | |
print("#######################################################################################") | |
print("Step2: rates_calculations.ipynb run started at "+ str(datetime.now(pytz.timezone('America/Los_Angeles')).strftime('%d-%m-%Y %H:%M:%S'))) | |
print("#######################################################################################") | |
Today = Today.strftime("%Y-%m-%d") |
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 scipy.stats.kde import gaussian_kde | |
from numpy import linspace | |
# input data | |
data = train.loss | |
# data =randn(10000) | |
# this create the kernel, given an array it will estimate the probability over that values | |
kde = gaussian_kde( data ) | |
# these are the values over wich your kernel will be evaluated | |
dist_space = linspace( min(data), max(data), 100 ) | |
# plot the results |
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
train.info() #### will give a summary for the entire data | |
train.describe() #### will give a summary for continuous variables in the data |