data.frame - How to do a data frame join with pandas? -
can explain info frame joins pandas
me based on example?
the first dataframe, let's phone call a
, looks this:
the sec dataframe, b
, looks this:
i want create plot in compare values column running
in a
in b
if string in column graph
same. (in example, first row in a
, b
have same graph
want compare running
value.)
i believe pandas.dataframe.join
for, cannot formulate code needed bring together info frames a
, b
correctly.
i think utilize merge
here:
>>> = pd.dataframe({"graph": ["as-22july06", "belgium", "cage15"], "running": [2, 879, 4292], "mod": [0.28, 0.94, 0.66], "eps": [220, 176, 1096]}) >>> b = pd.dataframe({"graph": ["as-22july06", "astro-ph", "cage15"], "running": [395.186, 714.542, 999], "mod": [0.67, 0.74, 0.999]}) >>> eps graph mod running 0 220 as-22july06 0.28 2 1 176 kingdom of belgium 0.94 879 2 1096 cage15 0.66 4292 >>> b graph mod running 0 as-22july06 0.670 395.186 1 astro-ph 0.740 714.542 2 cage15 0.999 999.000 >>> a.merge(b, on="graph") eps graph mod_x running_x mod_y running_y 0 220 as-22july06 0.28 2 0.670 395.186 1 1096 cage15 0.66 4292 0.999 999.000
join data.frame pandas ipython-notebook
No comments:
Post a Comment