Created
February 14, 2019 23:26
-
-
Save aialenti/bd1e56eb58bd8d00a7c3bb278315c71d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import pandas as pd | |
#from constants import * | |
#from src.commons import utils | |
#import matplotlib.pyplot as plt | |
#import numpy as np | |
# Read the list of all paintings (scraped data) | |
data = pd.read_csv('{}/data.csv'.format(DATA_FOLDER)) | |
for year in data['year'].unique(): | |
full_data = pd.DataFrame() | |
for idx, row in data[data['year'] == year].iterrows(): | |
# Load images results | |
tmp_data = pd.read_csv('{}/images_schemes/{}_data.csv'.format(OUTPUT_FOLDER, row.title)) | |
full_data = pd.concat([full_data, tmp_data], axis=0) | |
full_data = full_data.groupby(['points']).sum().reset_index() | |
full_data['perc'] = full_data['count'] / full_data['count'].sum() | |
# Merge colors | |
color_scheme = pd.read_csv('{}/color_scheme.csv'.format(OUTPUT_FOLDER)) | |
full_data = pd.merge(full_data, color_scheme, how='inner', left_on='points' | |
, right_on=color_scheme.columns[0]) | |
full_data['R'] = full_data['R'].apply(np.int) | |
full_data['G'] = full_data['G'].apply(np.int) | |
full_data['B'] = full_data['B'].apply(np.int) | |
full_data.to_csv('{}/years_proportions/{}.csv'.format(OUTPUT_FOLDER, year), | |
columns=['perc', 'R', 'G', 'B', 'H', 'S', 'V'], | |
index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment