For the sample file given below, how to go about converting the groupby keys to a dictionary and then assigning integer numbers to the keys? I wanted to be able to eventually iterate through the dictionary extracting the numbers from the dictionary for each respective key.
Here is my code so far:
import math
import pandas as pd
original_df = pd.read_csv('NewDatasetTotal4.csv')
original_df = original_df.astype(str)
length = original_df.original_class.count()
group_size = original_df.groupby('original_class').size()
colum_to_grab = 'original_class'
group_list = original_df.groupby(colum_to_grab)
# How to now convert the group_list.groups.keys() to a dictionary with
# pigs_size = 5
# goats_size = 3
# chickens_size = 7
# hens_size = 7
# sheep_size = 2
Can the assigned integers be in an array like [5, 3, 7, 7, 2]
Here is my data file:
slice_file_name fsID start end salience fold classID class_name original_class
1-1000020520400.wav 1 1 pigs
1-100004024000001.wav 1 1 pigs
1-10000406050001.wav 1 1 pigs
1-1000050120400.wav 1 1 pigs
1-1000050320400.wav 1 1 pigs
1-1000050520400.wav 1 2 goats
1-10000601400001000.wav 1 2 goats
1-1000060340000.wav 1 2 goats
1-100006070500.wav 1 3 chickens
1-100007020800.wav 1 3 chickens
1-100007024000001.wav 1 3 chickens
1-1000070320400.wav 1 3 chickens
1-100007050800.wav 1 3 chickens
1-100007064000001.wav 1 3 chickens
1-100010620400.wav 1 3 chickens
1-100040620400.wav 1 3 chickens
1-10006020500.wav 1 3 chickens
1-10006030500.wav 1 3 chickens
1-100060520400.wav 1 4 hens
1-10007020500.wav 1 4 hens
2-100070420400.wav 1 4 hens
2-100070540000.wav 1 4 hens
2-1313131313004.wav 1 4 hens
2-1313131313043.wav 1 4 hens
2-1313131313044.wav 1 5 sheep
2-150002020500.wav 1 5 sheep
2-150002060800.wav 1 5 sheep
2-150004022040001.wav 1 5 sheep
2-15000406050001.wav 1 5 sheep
2-150006014000001.wav 1 5 sheep
2-150006024000001.wav 1 5 sheep