How to create a lookup table in python when the dependent parameter value depends on multiple variables

人盡茶涼 提交于 2019-12-11 10:15:36

问题


I have a database like the following, in which the value of the parameter 'b' depends on the values of multiple other parameters, viz. a(1), a(2) ... a(n):

a(1),a(2),a(3),...,a(n) : b

and multiple lines like this. The value of 'n' is also dynamic and varies across various data sets.

What is the best way to construct a lookup table for this kind of data in Python?

One way could be using a nested dictionary with the values of a(i) as i-th level of key, but it seems too cumbersome to create such a dictionary dynamically.

Additional Information

I need the lookup table to find values of the variable b for different combinations of values of a(1), a(2) ... a(n).In many cases the values of a(i) is a range instead of a specific value. and its not a SQL database.

I basically have to loop through the the value set of various a(i) variables and find the appropriate value of the variable 'b' for that particular value set.

example data set:

a(1)    a(2)    b
1-2     1-2    5-15
1-2     3-4    16-30
3-10    1-4    10-30

来源:https://stackoverflow.com/questions/14725594/how-to-create-a-lookup-table-in-python-when-the-dependent-parameter-value-depend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!