<jupyter_start><jupyter_text>To calculate the infection rate of one area with regard to another, we apply the function Ro: Current Assets/Total Positive.<jupyter_code>def Ro_(a,b): 
    Ro_=(a/b)
    return Ro_

def Ro_by_region(): 
      
    current_risk_by_region['Ro_by_region'] = current_risk_by_region.apply(lambda row : Ro_(row['Actives_by_region'],row['PCR+']), axis = 1) 
   
    return current_risk_by_region
current_risk_by_region['Actives_by_region']=current_risk_by_region.iloc[:,0:2].sum(axis=1)
def Zone(a): 
    b=current_risk_by_region['Actives_by_region'].sum()
    Zone=(a/b)*100
    return Zone

def Risk_by_region(): 
      
    current_risk_by_region['Risk_by_region'] = current_risk_by_region.apply(lambda row : Zone(row['Actives_by_region']), axis = 1) 
   
    return current_risk_by_region
def Prob_risk(a): 
    b=current_risk_by_region['Risk_by_region'].max()
    Prob_risk=(a/b)*100
    return Prob_risk

def Risk_by_region_final(): 
      
    current_risk_by_region['Risk_by_region_final'] = current_risk_by_region.apply(lambda row : Prob_risk(row['Risk_by_region']), axis = 1) 
   
    return current_risk_by_region<jupyter_output><empty_output><jupyter_text>We apply the three functions that have been defined to the DataFrame.<jupyter_code>current_risk_by_region=Actives_by_region()
current_risk_by_region=Inmunes_by_region()
current_risk_by_region=Ro_by_region()
current_risk_by_region=Risk_by_region()
current_risk_by_region=Risk_by_region_final()
c=current_risk_by_region['Actives_by_region'].sum()
current_risk_by_region
df=pd.DataFrame()
df=current_risk_by_region[['CCAA','Risk_by_region_final']]
df=df.reset_index()
df=df.drop(columns='index')
df
from google.colab import drive
drive.mount('/content/drive')
df.to_csv('Risk_by_region.csv',index=False)
!cp Risk_by_region.csv "/content/drive/My Drive"<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11497326203208556, 'fraction_numerical': 0.006417112299465241, 'mean_word_length': 6.927966101694915, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '418644', 'license': 'MIT', 'n_tokens_mistral': 735, 'n_tokens_neox': 677, 'n_words': 99, 'path': 'Zona_riesgo_01.ipynb', 'repo_name': 'sedilo/Feature-engineering-against-Covid-19', 'size': '1870'}