Create a Table to a PNG file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Create a Table to a PNG file (/thread-37931.html) |
Create a Table to a PNG file - amanajosh - Aug-11-2022 Hi 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 per specific lot number. VAX_MANU and VAX_LOT is part of the original dataset so I am trying to find the most documented lot number for any manufacturer (Pzifer, Moderna, Johnson & Johnson) and then creating a table that has VAX_MANU, VAX_LOT and the frequency This 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') This article explained what went wrong. Am I correct in saying that what I'm doing here isn't permitted on Python? If so, what other ways can I have a small table of VAX_MANU, VAX_LOT, frequency of specific lot number?
|