<jupyter_start><jupyter_text>Notebook which connects to Companies House API and retrieves company information. eg. Cash owned<jupyter_code>import pandas as pd
financials = pd.read_csv('/Users/b1017579/Documents/PhD/Projects/10. ELECSIM/data/raw/companies/company_financials.csv')
financials = financials.dropna(how='all')
financials
financials_no_source = financials.drop(['Source','Unnamed: 7'], axis=1)
financials_no_stirling = financials_no_source.apply(lambda x: x.str.replace('£',''))

financials_no_source
# Convert k,m,b to 000, 000000, 000000000 respectively

def unit_to_000(column):
    column = (column.replace(r'[kmb]+$', '', regex=True).astype(float) * 
              column.str.extract(r'[\d\.]+([kmb]+)', expand=False).fillna(1).replace(['k','m','b'], [10**3, 10**6, 10**9]).astype(int))
    return column

financials_to_thousand = financials_no_stirling.copy()
financials_to_thousand[['cash_in_bank','total_liabilities','total_assets','turnover','net_assets']] = financials_no_stirling[['cash_in_bank','total_liabilities','total_assets','turnover','net_assets']].apply(lambda x: unit_to_000(x), axis=0)
financials_to_thousand

financials_to_thousand.to_csv('/Users/b1017579/Documents/PhD/Projects/10. ELECSIM/data/processed/companies/company_financials.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16104294478527606, 'fraction_numerical': 0.04217791411042945, 'mean_word_length': 8.125874125874127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '332839', 'license': 'MIT', 'n_tokens_mistral': 524, 'n_tokens_neox': 473, 'n_words': 61, 'path': 'notebooks/data_manipulation/power_plants_db/company_financial_details.ipynb', 'repo_name': 'alexanderkell/elecsim', 'size': '1304'}