Combining Strings from Two Columns in Data Plot

@mmack

You may want to join the pair together into a new list, with some kind of separator (a space) and use that for your X axis labels. There are lots of ways to do this (e.g., f strings, join(), string concatenation, format()).

One example:

data=[{'first':'jim', 'last':'slim'}, {'first':'bob', 'last':'builder'}, {'first':'joan', 'last':'baez'}]

full_names=['{0} {1}'.format(row['first'], row['last']) for row in data]

# full_names is:
['jim slim', 'bob builder', 'joan baez']
1 Like