Convert a table to an image

Hi. I am trying to create an image from a table and I do not know how to do that.

I am trying to create a table with the vaccine lot number and cardiovascular adverse events. I want to have a table where I have the values in descending order, with a limit of 15 in the table. The columns need to have VAX_MANU, VAX_LOT, and total number of cardiovascular adverse events

Here is my code:

## Understand value_counts()

covid_vaers_cardio['VAX_LOT'].value_counts()

## Create a count for all the Lot Numbers

total_number = covid_vaers_cardio['VAX_LOT'].value_counts()

## Create a table

covid_vaers_lot = covid_vaers_cardio[['VAX_MANU', 'VAX_LOT', 'total_number']]

Error: KeyError: “[‘total_number’] not in index”

Another attempt:

## Understand value_counts()

covid_vaers_cardio['VAX_LOT'].value_counts()

## Create a count for all the Lot Numbers

total_number = covid_vaers_cardio['VAX_LOT'].value_counts()

## Create a table

covid_vaers_lot = covid_vaers_cardio['VAX_MANU'].merge(total_number, how='outer')

Error:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_18536/3237736396.py in
----> 1 covid_vaers_lot = covid_vaers_cardio[‘VAX_MANU’].merge(total_number, how=‘outer’)

~\anaconda3\lib\site-packages\pandas\core\generic.py in getattr(self, name)
5485 ):
5486 return self[name]
→ 5487 return object.getattribute(self, name)
5488
5489 def setattr(self, name: str, value) → None:

AttributeError: ‘Series’ object has no attribute ‘merge’

Need some help

@MfonobongAmana

The merge doesn’t work this way! Nor can you create a new data frame with this code:
covid_vaers_lot = covid_vaers_cardio[['VAX_MANU', 'VAX_LOT', 'total_number']]

Understand this documentation and try to figure out where you are going wrong.

Hint: the merge will require some common key/ index or columns to merge on.

You have a comment like ## Understand value_counts(). So try to understand the results of this code,
covid_vaers_cardio['VAX_LOT'].value_counts(),
and compare them with the results of this code
covid_vaers_cardio[['VAX_MANU', 'VAX_LOT']].

Not the values, the structure of the resultant series and the data frame.

Let me know your comments, will discuss them based on your observations!

Hi. Sorry I have been away for some time. I am currently looking at this and making sense of what you are trying to get at here

This:

covid_vaers_cardio[['VAX_MANU', 'VAX_LOT']]

is merely just obtaining 2 columns from a larger dataset

This:

covid_vaers_cardio['VAX_LOT'].value_counts()

gave me 2 columns showing me a first 5 most populous and least populous of lot number and the second column was the frequency or total count.

I renamed that code as total_number and tried to create a column alongside VAX_LOT and VAX_MANU. However, it doesn’t work like that because the piece of code above is not a column in the previous filtered dataset

Essentially, I’m trying to create a new table mixing 2 columns from a filtered dataset and a column with the most prevalent lot number associated with the major cardiovascular symptoms. But you see that I am struggling to achieve that