Joining two tables together - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Joining two tables together (/thread-11700.html) |
Joining two tables together - tryingtolearnpython - Jul-22-2018 Hi everyone, I did the following: # The next lines are provided for you. They create a table # containing only the Alaska information and one containing # only the Minnesota information. ak = murder_rates.where('State', 'Alaska').drop('State', 'Population').relabeled(1, 'Murder rate in Alaska') mn = murder_rates.where('State', 'Minnesota').drop('State', 'Population').relabeled(1, 'Murder rate in Minnesota') # Fill in this line to make a table like the one pictured above. ak_mn = Table().with_column("Year", ak.column(0), "Murder rate in Alaska", ak.column(1), "Murder rate in Minnesota", mn.column(1)) ak_mn Is there an easier / better way to do it? I'm not sure if the highlighted part above is the best way to solve this. |