# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---




# +
from pathlib import Path

import pandas as pd
import numpy as np
# -

try:
    import common
    DATA = common.dataDirectory()
except ImportError:
    DATA = Path().resolve() / 'data'

for entry in DATA.iterdir():
    if entry.is_file():
        print(entry.name)

techMat_csv = DATA / 'hw6_tech_matrix.csv'
fdQ2_csv = DATA / 'hw6_fd_q2.csv'
fdQ5_csv = DATA / 'hw6_fd_q5.csv'
intervMat_csv= DATA / 'interv_mat.csv'

techMat = pd.read_csv(techMat_csv)
fdQ2 = pd.read_csv(fdQ2_csv)
fdQ5= pd.read_csv(fdQ5_csv)
intervMat = pd.read_csv(intervMat_csv)

intervMat.head(3)

# +
#np.argwhere(np.isnan(techMat_del))
# -

techMat = pd.DataFrame(techMat).fillna(0)
techMat = techMat.apply(pd.to_numeric, errors='coerce').dropna(axis='columns').to_numpy(dtype=float,na_value=0)
techMat_inv = np.linalg.inv(techMat)



fdQ2 = pd.DataFrame(fdQ2).fillna(0)
fdQ2 = fdQ2.apply(pd.to_numeric, errors='coerce').dropna(axis='columns').to_numpy(dtype=float,na_value=0)

sQ2 = np.matmul(techMat_inv, fdQ2)
sQ2 # need to write to csv back

intervMat = pd.DataFrame(intervMat).fillna(0)
intervMat = intervMat.apply(pd.to_numeric, errors='coerce').dropna(axis='columns').to_numpy(dtype=float,na_value=0)

intervMat

gQ2 = np.matmul(intervMat, sQ2)

intervMat.shape



StarcoderdataJupyterScriptsDedupFiltered