Пример #1
0
def main():
    try:
        sheet_name = 'Index'
        df_temp1 = df_new.parse(sheet_name)
        df_temp2 = df_old.parse(sheet_name)
        df_temp1 = df_temp1[df_temp1['Index'] == 'Equity']
        df_temp2 = df_temp2[df_temp2['Index'] == 'Equity']
        sheet_names_new = df_temp1['Unnamed: 1'].tolist()
        sheet_names_old = df_temp2['Unnamed: 1'].tolist()
        writer = pd.ExcelWriter(output_file, mode='w')
        for name in sheet_names_new:
            if name in sheet_names_old:
                print(name)
                df1 = df_new.parse(name)
                df2 = df_old.parse(name)
                date1 = f.date_extract(df1)
                month_date1 = str(date1.month)+'_'+str(date1.day)
                logging.debug(" Month df1 : %s",month_date1)
                date2 = f.date_extract(df2)
                month_date2 = str(date2.month)+'_'+str(date2.day)
                logging.debug(" Month df2 : %s",month_date2)
                assert(date1.month - date2.month == 1)
                logging.debug("Assertion correct")
                dftmp1, qty1, mkt1, pnav1 = f.create_df(df1,month_date1)
                dftmp2, qty2, mkt2, pnav2 = f.create_df(df2,month_date2)
                logging.debug("new df created")
                dftmpx1 = dftmp1[dftmp1['INDUSTRY'].notna()]
                logger.debug("df1_shape : %s",dftmpx1.shape)
                dftmpx2 = dftmp2[dftmp2['INDUSTRY'].notna()]
                logger.debug("df2_shape : %s",dftmpx2.shape)
                dftmpx1 = dftmp1[dftmp1['ISIN Code'].notna()]
                print(dftmpx1.columns)
                dftmpx2 = dftmp2[dftmp2['ISIN Code'].notna()]
                #dftmpx1 = dftmp1[dftmp1[nav].notna()]
                #dftmpx2 = dftmp2[dftmp2[nav].notna()]
                dftmp = pd.merge(dftmpx1, dftmpx2, how = 'outer', on = ['Stock_Name', 'INDUSTRY', 'ISIN Code'])
                dftmp = dftmp.replace(np.nan, 0)
                dftmp['change'] = dftmp[[qty1, qty2]].apply(lambda x: f.find_change(x[0],x[1]), axis=1)
                dftmp['change_val'] = dftmp[[qty1, qty2]].apply(lambda x: f.find_act_change(x[0],x[1]), axis=1)
                dftmp.to_excel(writer, sheet_name=name)
        writer.save()
    except Exception:
        logger.debug("Unexpected Error")
Пример #2
0
import functions
import numpy as np
from language import max_letters, language_tags
import pandas as pd
import config

word_data = []
language_data = []
master_dic = []
count = 0

#this function is used to generate dictionary for words in german and english language, and produces a final csv
#which contains each word transformed into a vector and its label.
for tag in config.language_tags.keys():
    print('generating dictionary for ' + tag)
    dic = functions.create_df(tag, max_letters)
    for word in dic:
        master_dic.append(word)
    vct = functions.convert_dic_to_vector(dic, max_letters)
    for vector in vct:
        word_data.append(vector)
    output_vct = functions.create_output_vector(count, len(language_tags))
    for i in range(len(vct)):
        language_data.append(output_vct)
    count += 1

arr = []
for i in range(len(word_data)):
    entry = []
    entry.append(master_dic[i])
    for digit in language_data[i]:
Пример #3
0
        # Power point check
        pp_check = True
        while pp_check:
            input_pp = int(input("[3/3] Power points:"))
            req_pp = int(main_level.get(input_level).get("points")) - input_pp
            if req_pp < 0:
                print("Are you sure?")
            else:
                pp_check = False

        # Mapping the user input to return correct requirements
        req_pp = int(main_level.get(input_level).get("points")) - input_pp
        req_coin = main_level.get(input_level).get("coins")

        # Store the user input data into database
        db = create_df()

        if check_brawler(db, input_brawler):
            db = update_brawler(db, input_brawler, input_level, req_pp,
                                req_coin)
        else:
            db = add_brawler(db, input_brawler, input_level, req_pp, req_coin)

        db = order_database(db)
        save_df(db)

        # Output stage to the user
        print("\n{}".format(db))

        print("\nMake change to another Brawler?")
        make_change_input = input("[y/n]:")
Пример #4
0
import sys
from functions import give_one, create_df
from data_processing.data_proc import give_three
from funs import give_two

if __name__ == '__main__':
    df = create_df()
    df['one'] = give_one()
    df['two'] = give_two()
    df['three'] = give_three()
    if df.shape[1] == 4:
        print('Main run succesful')
    else:
        print('Error')
        sys.exit(1)
Пример #5
0
def test_create_df():
    df = f.create_df()
    if df is not None:
        assert True
    else:
        assert False