Created
July 21, 2021 19:00
-
-
Save vikjam/546bc13aa2b2b5b37673f3c1e63b1d3c to your computer and use it in GitHub Desktop.
CSV to dict via pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from io import StringIO | |
params_df = pd.read_csv( | |
StringIO( | |
"parameter,value\ntheta,0.1\nbeta,0.5" | |
) | |
) | |
params_df | |
# parameter value | |
# 0 theta 0.1 | |
# 1 beta 0.5 | |
params_dict = params_df.set_index('parameter').to_dict('index') | |
theta = params_dict['theta']['value'] | |
theta | |
# 0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment