<jupyter_start><jupyter_text>Finalizing the codes:<jupyter_code>inside = []  #Date
for i in d["Date"]:
    inside.append(i)
inside
outside = list(np.tile("10-Jan-2019",632))    #Expiry
hier_index = list(zip(outside,inside))
hier_index = pd.MultiIndex.from_tuples(hier_index)
np.random.seed(101)
df1 = pd.DataFrame(data = np.round(rn(632,9),2),index = hier_index,columns = ['x','a','b','c','d','e','f','g','h'])
df1.loc["10-Jan-2019"].loc[["03-Jan-2019"],["x"]] 
df1
d
temp = set(inside)
temp
temp = list(temp)
temp
temp.sort()
temp
df1.head(2)
df1.index.names = ["outside","inner"]
df1.head(2)
df1.loc["10-Jan-2019"].loc[["03-Jan-2019"],["x"]]
d
t = d
t = t.set_index("Date")
t
t["Close_x"].loc["03-Jan-2019"].mean()
t["Close_x"].loc["04-Jan-2019"].mean()
t["Close_x"].loc["07-Jan-2019"].mean()
t["Close_x"].loc["08-Jan-2019"].mean()
t["Close_x"].loc["09-Jan-2019"].mean()
t["Close_x"].loc["10-Jan-2019"].mean()
close_list = []
for i in temp:
    tt = np.round(t["Close_x"].loc[i].mean(),decimals = -2)
    close_list.append(tt)
close_list<jupyter_output><empty_output><jupyter_text>here..<jupyter_code>close_list
temp
df1.head()
k = 0
for i in temp:
    df1.loc["10-Jan-2019"].loc[[i],["x"]] = close_list[k]
    k+=1
df1
def addsubround(x,a,b,c,d,e,f,g,h):
    a = x+100
    b = x+200
    c = x+300
    d = x+400
    e = x-100
    f = x-200
    g = x-300
    h = x-400
    return [a,b,c,d,e,f,g,h]
l = []
t = df1.loc["10-Jan-2019"].loc[["03-Jan-2019"],["x"]]
l = addsubround(t,a,b,c,d,e,f,g,h)
int((df1.loc["10-Jan-2019"].loc[["03-Jan-2019"],["x"]]).mean())
l[0]
df1.loc["10-Jan-2019"].loc[["03-Jan-2019"],["x"]]
k = 0
for i in temp:
    tt = int((df1.loc["10-Jan-2019"].loc[[i],["x"]]).mean())
    l = []
    l = addsubround(tt,a,b,c,d,e,f,g,h)
    df1.loc["10-Jan-2019"].loc[[i],["a"]] = l[0]
    df1.loc["10-Jan-2019"].loc[[i],["b"]] = l[1]
    df1.loc["10-Jan-2019"].loc[[i],["c"]] = l[2]
    df1.loc["10-Jan-2019"].loc[[i],["d"]] = l[3]
    df1.loc["10-Jan-2019"].loc[[i],["e"]] = l[4]
    df1.loc["10-Jan-2019"].loc[[i],["f"]] = l[5]
    df1.loc["10-Jan-2019"].loc[[i],["g"]] = l[6]
    df1.loc["10-Jan-2019"].loc[[i],["h"]] = l[7]
    k+=1
df1<jupyter_output><empty_output><jupyter_text>RESULT:<jupyter_code>df1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2881280569141841, 'fraction_numerical': 0.10538016896398399, 'mean_word_length': 4.514705882352941, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '295416', 'license': 'MIT', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1080, 'n_words': 130, 'path': 'Data-Science-HYD-2k19/Projects/codes/PROJECT 1 (Jupiter ) ( Bank Nifty )/Merge BankNift and Data/Multi-Indexing ( for BankNifty and Data ).ipynb', 'repo_name': 'Sanjay9921/Python', 'size': '2249'}