<jupyter_start><jupyter_text>Import from the CSV<jupyter_code>import numpy as np
import csv
import pandas as pd
data_name = 'PortfolioSimulation - OurPortfolio.csv'
col_headers = ['Kaufdatum', 'SXR8 Value', 'EUNH Value', 'SXRT Value', 'IBCS Value', 'IUS7 Value', 'EUNH Interest per share', 'IBCS Interest per share',
'IUS7 Interest per share'];
data_dict = {}
with open(data_name, newline='') as csvfile:
    data_reader = csv.reader(csvfile, delimiter=',')
    for ln, row in enumerate(data_reader):    
        for col_header in col_headers:
            if row[0] == col_header:
                #print(row[0])
                #print(row[1:])
                data_dict.update({row[0] : row[1:]})
                pass
            
        #else:
        #    print('skip', row[0])
data_dict.keys()
df = pd.DataFrame(data_dict)
df.head()<jupyter_output><empty_output><jupyter_text>and make it the right types<jupyter_code>df.index=pd.to_datetime(df.Kaufdatum);
df['Kaufdatum'] = pd.to_datetime(df.Kaufdatum);

# get the prices
df['SXR8_Price'] = df['SXR8 Value'].astype(float);
df['EUNH_Price'] = df['EUNH Value'].astype(float);
df['SXRT_Price'] = df['SXRT Value'].astype(float);
df['IBCS_Price'] = df['IBCS Value'].astype(float);
df['IUS7_Price'] = df['IUS7 Value'].apply(lambda x: '0' if x == '' else x);
df['IUS7_Price'] = df['IUS7_Price'].astype(float);

# get the interest per share
df['EUNH_IPS'] = df['EUNH Interest per share'].apply(lambda x: x.strip('€'));
df['EUNH_IPS'] = df['EUNH_IPS'].apply(lambda x: '0' if x == '' else x);
df['EUNH_IPS'] = df['EUNH_IPS'].astype(float);

df['IBCS_IPS'] = df['IBCS Interest per share'].apply(lambda x: x.strip('€'));
df['IBCS_IPS'] = df['IBCS_IPS'].apply(lambda x: '0' if x == '' else x);
df['IBCS_IPS'] = df['IBCS_IPS'].astype(float);

df['IUS7_IPS'] = df['IUS7 Interest per share'].apply(lambda x: x.strip('€'));
df['IUS7_IPS'] = df['IUS7_IPS'].apply(lambda x: '0' if x == '' else x);
df['IUS7_IPS'] = df['IUS7_IPS'].astype(float);

df.head()<jupyter_output><empty_output><jupyter_text>finally clean it up<jupyter_code>df = df.drop(columns=col_headers[1:])
df.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19076492537313433, 'fraction_numerical': 0.012126865671641791, 'mean_word_length': 4.781671159029649, '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': '53530', 'license': 'MIT', 'n_tokens_mistral': 854, 'n_tokens_neox': 841, 'n_words': 168, 'path': 'Import_Test.ipynb', 'repo_name': 'fretchen/vanilla_flask', 'size': '2144'}