musif.process package¶
Submodules¶
musif.process.constants module¶
- musif.process.constants.PRESENCE = 'Presence_of'¶
Constant to create columns regarding presenc of an instrument or not.
- musif.process.constants.voices_list = ['sop', 'ten', 'alt', 'bar', 'bbar', 'bass']¶
List of prefixes for singers used to find voices columns
- musif.process.constants.voices_list_prefixes = ['PartSop_', 'PartTen_', 'PartAlt_', 'PartBar_', 'PartBbar_', 'PartBass_']¶
List of prefixes Part_ + each element of voices_list
musif.process.processor module¶
- class musif.process.processor.DataProcessor(info: str | pandas.DataFrame, *args, **kwargs)[source]¶
Bases:
object
Processor class that treats columns and information of a DataFrame
This operator processes information from a DataFrame or a .csv file. It deletes unseful columns for analysis and saves important ones. Also saves data in several files in .csv format. The main method .process() returns a DataFrame and saves data. Requires to have a labels file in ./internal_data directory containing each label assigned to each score. …
- data¶
DataFrame extracted with FeaturesExtractor containing all info.
- Type:
DataFrame
- info¶
Path to .csv file or Dataframe containing the information from FeaturesExtractor
- Type:
str
- __init__(info: str | pandas.DataFrame, *args, **kwargs)[source]¶
- Parameters:
*args (str) – Could be a path to a .yml file, a PostProcessConfiguration object or a dictionary. Length zero or one.
*kwargs (str) – Key words arguments to construct
kwargs[info] (Union[str, DataFrame]) – Either a path to a .csv file containing the information either a DataFrame object fromm FeaturesExtractor
- delete_files_without_harmony()[source]¶
Deletes files (actually rows in the DataFrame) that didn’t have a proper harmonic analysis and, there fore, got a value of 0 in ‘Harmony_Available’ column
- delete_undesired(**kwargs) None [source]¶
Deletes not necessary columns and rows for statistical analysis.
If keyword arguments are passed in, they overwrite those found into configurationg file
- Parameters:
**kwargs (str, optional) – Any value from config.yml can be overwritten by passing arguments to the method
- Raises:
KeyError – If any of the columns required to delete is not found in the original DataFrame.
- group_columns() None [source]¶
Groups Key_*_PercentageMeasures, Key_Modulatory and Degrees columns. Into bigger groups for agregated analysis, keeping the previous ones. Also deletes unnecesary columns for analysis.
- process() pandas.DataFrame [source]¶
Main method of the class. Removes NaN values, deletes unuseful columns and merges those that are needed according to config.yml file.
- Return type:
Dataframe object
- save(dest_path: str | PurePath, ext='.csv', ft='csv', **kwargs) None [source]¶
Saves current information into a file given the name of dest_path
To load one of those file, remember to set the index to musif.extract.constant.ID, and, if windows are used, to musif.extract.constant.WINDOW_ID:
`python df = pd.read_csv('window_alldata.csv').set_index(['Id', 'WindowId']) `
- Parameters:
dest_path (str or Path) – Path to directory where the file will be stored; a suffix like _metadata.csv will be added.
ext (str) – Extension used to save files. Use .gz, .xz, .zip etc. to compress the files. Default: .csv
ft (str) – Type of file for saving. The filetype must be supported by pandas, e.g. to_csv, to_feather, to_parquet, etc. Default: csv
musif.process.utils module¶
- musif.process.utils.merge_dataframes(name: str, dest_path: str) None [source]¶
Takes two dataframes and joins them, apart from deleting rows that are all nans. This is intended for cases where all extraction of a folder cannot be done all at once.
- Return type:
Dataframe with the extracted features as a concatenation of two dataframes