I am rather new to coding, and tutorial hell has started to show it's toll. I need help to graph data that are both strings. I have attempted transforming the data using matplotlib, and pandas. However, I seem to not be able to graph them as the ones I have used require int type data.
I have managed to group the data using df.groupby(['type', 'url']).sum()
My current goal is to get the sum (how many are in each type) of each group and graph them. Dataset link below Kaggle - Malicious Links
Edit: Had an Image here. Made it into a code block instead:
df = pd.read_csv('/content/malicious_phish.csv')
df
<output: csv contents>
df.shape
<output: 651191, 2>
df.groupby(['type', 'url']).sum()
<output: corrupted text in a table>
Not sure if this is any better
I have tried using len()
and .sum()
or .count()
. I have started to read into the matplotlib and pandas library on functions and tools for me to use, and hopefully use to resolve this problem.
CodePudding user response:
from collections import Counter
Counter(df['Wafer'])
To plot the dict
result, the follwing link is helpful https://stackoverflow.com/a/52572237/16353662.