<jupyter_start><jupyter_text>Polarizability 2018<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>You can get the polarizability table as csv from [this link](https://www.tandfonline.com/action/downloadTable?id=T0001&doi=10.1080%2F00268976.2018.1535143&downloadType=CSV).<jupyter_code>df = pd.read_csv('data/T0001-10.1080%2F00268976.2018.1535143.csv')
df.info()
df.head()<jupyter_output><empty_output><jupyter_text>Find empty values in the csv, replace the with `None` and forward fill the last value to complete the table.<jupyter_code>mask = ~df['Z'].str.isdigit()
df.loc[mask, 'Z'] = None
df.loc[mask, 'Atom'] = None

df.loc[:, 'Z'] = df['Z'].ffill()
df.loc[:, 'Atom'] = df['Atom'].ffill()
df.head()<jupyter_output><empty_output><jupyter_text>We will only need the recommended values and their uncertainties.<jupyter_code>df[df['Comments'] == 'recommended']<jupyter_output><empty_output><jupyter_text>Extract the numerical values and the errors from the strings.<jupyter_code>df.loc[:, 'αD value'] = df['αD'].str.extract(r'^(\d+\.\d+|\d+)', expand=False).astype(float)
df.loc[:, 'αD error'] = df['αD'].str.extract(r'±\s*(\d+\.\d+|\d+)', expand=False).astype(float)
df.head(15)<jupyter_output><empty_output><jupyter_text>Update the polarizability values in the `elements.db`<jupyter_code>from mendeleev import get_session, Element
session = get_session()
alpha = df[df['Comments'] == 'recommended']
alpha.info()<jupyter_output><empty_output><jupyter_text>Check if there are any elements multiply defined<jupyter_code>(alpha.Z.value_counts() > 1).sum()
for i, row in alpha.iterrows():
    if int(row['Z']) <= 118:
        e = session.query(Element).filter(Element.atomic_number == int(row['Z'])).one()
    
        print(e.symbol, e.dipole_polarizability, e.dipole_polarizability_unc)
        print(row['αD value'], row['αD error'])
        e.dipole_polarizability = row['αD value']
        e.dipole_polarizability_unc = row['αD error']
        session.add(e)
session.commit()
session.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17073170731707318, 'fraction_numerical': 0.03414634146341464, 'mean_word_length': 6.431159420289855, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '149761', 'license': 'MIT', 'n_tokens_mistral': 822, 'n_tokens_neox': 750, 'n_words': 131, 'path': 'notebooks/polarizability2018.ipynb', 'repo_name': 'kalvdans/mendeleev', 'size': '2050'}