I have Pandas DataFrame and I am trying to create a list freqs
that contains the frequency of elements of a column (of the DataFrame) matching the last column of the DataFrame.
freqs = []
for i in range(len(df.colums)-1):
counter = 0
result = row[-1]
for row in df.iterrows():
if row[i] == result:
counter += 1
freqs.append(counter / len_df)
print(freqs)
This is the code I have written but I find it too slow and less close to the panda way of solving it.