I have a question related to the df['columnA'].value_counts() method and a previous post here: Count frequency of values in pandas DataFrame column
Take this example DataFrame:
fake_data = {'columnA': ['XAVY', 'XAVY', 'XAVY', 'XAVY', 'XAVY', 'AXYV', 'AXYV', 'AXYV', 'AXYV', 'AXYV', 'AXYV']}
df = pd.DataFrame(fake_data, columns = ['columnA'])
df
I am trying to determine the frequency of each letter (X,A,V,Y) at each position in the string in this column.
In this example, position 0 would be 54% A, 46% X, position 3 would be 46% Y, 54% V...and so on.
def countFreq(df)which will count occurrence of X in series/column - record. Pass yourdf[columnA]as an input parameter to this method. Within thecountFreq(df)create a DICT , with keys like ,dictFreq['X']anddictFreq['A'], etc . Append count of letters to these dict keys as values.