Skip to content

Instantly share code, notes, and snippets.

@batu
Created May 3, 2019 22:49
Show Gist options
  • Save batu/9adab925896ed3766fe1b63fc9f1e1c5 to your computer and use it in GitHub Desktop.
Save batu/9adab925896ed3766fe1b63fc9f1e1c5 to your computer and use it in GitHub Desktop.
down_sized_altair = []
img_data = []
img_shape = down_sized[10].shape
for index, image in enumerate(down_sized[0:10]):
for y in range(img_shape[0]):
for x in range(img_shape[1]):
pixel_color = image[y][x]/255
img_data.append((index, x+.5, img_shape[0]-y-.5, rgb2hex(pixel_color), explore_counts[index]))
down_sized_altair.append(img_data)
down_sized_altair = np.array(down_sized_altair)
reshaped_ds = down_sized_altair.reshape(down_sized_altair.shape[0] * down_sized_altair.shape[1], down_sized_altair.shape[2])
images_pd = pd.DataFrame({
"index": reshaped_ds[:,0],
'x': reshaped_ds[:,1],
'y': reshaped_ds[:,2],
"color" : reshaped_ds[:,3],
"explore_counts" : reshaped_ds[:,4]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment