DSIC-Bayes-continuous/datapreparator.py

23 lines
602 B
Python
Raw Normal View History

2021-05-26 13:32:48 +02:00
from copy import deepcopy
import pandas as pd
class DataPreparator:
genre_dict = {
"blues" : 1,
"classical" : 2,
"country" : 3,
"disco" : 4,
"hiphop" : 5,
"jazz" : 6,
"metal" : 7,
"pop" : 8,
"reggae" : 9,
"rock" : 10
}
def prepare_data(df: pd.DataFrame) -> pd.DataFrame:
data = deepcopy(df)
column = df["label"].apply(lambda x: DataPreparator.genre_dict[x])
data.insert(0, 'genre', column, 'float')
data = data.drop(columns=['filename', 'label', 'length'])
return data