Q:

Using pandas to merge data and output Json

I have several different CSV files like this: 
one: 

iq, name 
69, joe
122, james
...

two:

iq_start, iq_end, category
120,500, Very Superior
120,129,    Superior
110,119,    High Average
90,109, Average
80,89,  Low Average
70,79,  Borderline
0,69,   Extremely Low

three: 
iq, career
69 , manual work
122, doctor

I want to pull the data into pandas , and output the data like this 
[
"122" = {
    "name" : "james",
    "career" : "doctor"
    "category" : "Superior"
    },

"69" = {
    "name" : "joe",
    "career" : "manual work"
    "category" : "Extremely Low"
    }

]

Can panda pull this off or get me some of the way?

A:

Here is the code, but are you sure there are not two person with the same IQ?
import pandas as pd
import io

one="""iq, name
69, joe
120, james"""

two="""iq_start, iq_end, category
130,500, Very Superior
120,129,    Superior
110,119,    High Average
90,109, Average
80,89,  Low Average
70,79,  Borderline
0,69,   Extremely Low"""

three="""iq, career
69 , manual work
120, doctor"""

df1 = pd.read_csv(io.BytesIO(one), skipinitialspace=True)
df2 = pd.read_csv(io.BytesIO(two), skipinitialspace=True)
df3 = pd.read_csv(io.BytesIO(three), skipinitialspace=True)

iqmap = pd.Series(df2.category.values, index=df2.iq_start).sort_index()

df = pd.merge(df1, df3)
df["category"] = iqmap.asof(df.iq).values
df.set_index("iq", inplace=True)
df.T.to_dict()

output:
{69: {'career': 'manual work', 'category': 'Extremely Low', 'name': 'joe'},
 120: {'career': 'doctor', 'category': 'Superior', 'name': 'james'}}

