Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
frequency tables
#1
Hello I am trying to get a frequency table with 3 but I can only get it to print 1 at a time. Can Anyone help?

Using the code cell below, create and print three frequency tables of the amino acid letters in each of the positions 222, 439 and 614.

#dataset:

import pandas as pd
from pandas.api.types import CategoricalDtype

# Read in SARS-CoV-2 Spike Protein Sequences into a pandas dataframe
spike_df = pd.read_csv('spike_proteins.csv')

# Set the type of the variable month_name as categorical ordinal so that plots and tables are ordered chronologically
cat_type = CategoricalDtype(categories=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ordered=True)
spike_df['month_name'] = spike_df['month_name'].astype(cat_type)

# Output the first 10 rows
print(spike_df.head(10))

# Output the number of rows and columns
spike_df.shape
#my_code
import numpy as np
import pandas as pd
my_tab = pd.crosstab(index=spike_df["position_222"],
                    columns = "count")
my_tab
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020