# ---
# 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 tableschema import Table
from goodtables import validate
import datapackage

import pandas as pd

# ## LC-impact to US-EPA elementary flows

lcimpact_us_epa_ef_names_df=pd.read_csv('lcimpact_to_US_EPA_names.csv')
lcimpact_us_epa_ef_names_df.head(1)

# one to one ?

lcimpact_us_epa_ef_names_df\
[lcimpact_us_epa_ef_names_df.US_EPA_Name.duplicated(keep=False)].dropna()

lcimpact_us_epa_ef_names_df\
[lcimpact_us_epa_ef_names_df['LC-IMPACT_Name'].duplicated(keep=False)].dropna()

# assuming equal to relation would be assuming `Methane` and `fossil methane` are the same.

lcimpact_us_epa_ef_names = datapackage.Package()

# +
#lcimpact_us_epa_ef_names=Table('../raw/lcimpact_to_US_EPA_names.csv')
# -

lcimpact_us_epa_ef_names.infer('lcimpact_to_US_EPA_names.csv')

try:
    lcimpact_us_epa_ef_names.read(keyed=True)
except:
    print('not working')

report_lcimpact_us_epa_ef_names=validate('US_EPA_temp_increase.csv')

if len(report_lcimpact_us_epa_ef_names['tables'][0]['errors'])==0 : print('no errors found')

lcimpact_us_epa_ef_names.descriptor['title']=\
'correspondance between IPCC and US-EPA flow names'

lcimpact_us_epa_ef_names.descriptor['license'] =\
[{ "name": "MIT", 
  "path": "https://opensource.org/licenses/MIT", 
  "title": "The MIT License"}]

# we should probably add the provenance too.

lcimpact_us_epa_ef_names.commit()

lcimpact_us_epa_ef_names.save('../final_tables/lcimpact_to_US_EPA_names.json')

# ## 



StarcoderdataJupyterScriptsDedupFiltered