In [1]:
import pandas as pd

import pickle

Load


In [2]:
with open('../array_ROME1_fusion.pickle', 'rb') as f:
    ROME1_fusion = pickle.load(f)

In [3]:
with open('../suggestions.pickle', 'rb') as f:
    suggestions = pickle.load(f)

In [4]:
ROME_df = pd.read_csv('../referentiels/referentiel_ROME/20150921_arboprincipale28427_ROME.csv', index_col=0, sep='|', dtype=str)
OGR_df = pd.read_csv('../referentiels/referentiel_OGR/20150921_arboprincipale28427_OGR.csv', sep='|', dtype=str).set_index('OGR')
NAF_df = pd.read_csv('../referentiels/referentiel_NAF/naf2008_liste_n5_nouveau_header.csv', sep='|', encoding="utf-8").set_index(['NAF'])

With ROMEbis


In [5]:
ROMEbis_df = pd.read_csv('../ROMEbis_df.csv', index_col=0, sep='|', dtype=str)

In [6]:
with open('../array_ROMEbis.pickle', 'rb') as f:
    ROMEbis_NAF = pickle.load(f)

Output

Without ROMEbis


In [ ]:
with open('../tableau_LBB.csv', 'w') as f:
    headers = ['ROME', 'ROME_label', 'APE700', 'APE700_label', 'nb_embauches']
    f.write(','.join(headers) + '\n')
    
    for ROME_index in range(len(ROME_df)):
        ROME = ROME_df.index[ROME_index]
        ROME_label = ROME_df.loc[ROME].label

        for NAF_index in range(len(NAF_df)):
            NAF = NAF_df.index[NAF_index]
            NAF_label = NAF_df.loc[NAF].label

            if suggestions[NAF_index, ROME_index] == 0.:
                continue

            count = ROME1_fusion[NAF_index, ROME_index, :].sum()

            if count > 0:
                str_to_write = '{},"{}",{},"{}",{}'.format(
                    ROME,
                    ROME_label,
                    NAF,
                    NAF_label,
                    int(count),
                    )

                str_to_write += '\n'

                f.write(str_to_write)

With ROMEbis

NB : Le filtre éditorial sur les couples (ROME, NAF) à afficher n'existe pas encore pour les ROMEbis. C'est le même qui est utilisé.


In [9]:
with open('../tableau_LBB_ROMEbis.csv', 'w') as f:
    headers = ['ROMEbis', 'ROMEbis_label', 'APE700', 'APE700_label', 'nb_embauches']
    f.write(','.join(headers) + '\n')
    
    for ROMEbis_index in range(len(ROMEbis_df)):
        ROMEbis = ROMEbis_df.index[ROMEbis_index]
        ROMEbis_label = ROMEbis_df.loc[ROMEbis].label

        for NAF_index in range(len(NAF_df)):
            NAF = NAF_df.index[NAF_index]
            NAF_label = NAF_df.loc[NAF].label

            ROME = ROMEbis_df.loc[ROMEbis].ROME
            ROME_index = ROME_df.index.get_loc(ROME)
            if suggestions[NAF_index, ROME_index] == 0.:
                continue
                
            count = ROMEbis_NAF[NAF_index, ROMEbis_index]

            if count < 10:
                continue

            if count > 0:
                str_to_write = '{},"{}",{},"{}",{}'.format(
                    ROMEbis,
                    ROMEbis_label,
                    NAF,
                    NAF_label,
                    int(count),
                    )

                str_to_write += '\n'

                f.write(str_to_write)

In [ ]: