Created
August 19, 2018 18:21
-
-
Save bbennett36/601ab61291c5b26982bcaea473a08891 to your computer and use it in GitHub Desktop.
iterate through slive of list
This file contains hidden or 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
feats = ['post', 'odds'] | |
i_start = 0 | |
i_end = 4 | |
total_size = len(classes) | |
print(classes[i_start:i_end]) | |
while i_start < total_size: | |
print(pclass) | |
first = classes[i_start:i_start+1][0] | |
second = classes[i_start+1:i_start+2][0] | |
third = classes[i_start+2:i_start+3][0] | |
fourth = classes[i_start+3:i_start+4][0] | |
print(first) | |
temp1 = winners.loc[winners['class'] == first] | |
temp2 = winners.loc[winners['class'] == second] | |
temp3 = winners.loc[winners['class'] == third] | |
temp4 = winners.loc[winners['class'] == fourth] | |
counts1 = temp1['new_odds'].value_counts(normalize=True).reset_index() | |
counts2 = temp2['new_odds'].value_counts(normalize=True).reset_index() | |
counts3 = temp3['new_odds'].value_counts(normalize=True).reset_index() | |
counts4 = temp4['new_odds'].value_counts(normalize=True).reset_index() | |
fig, (ax1, ax2, ax3, ax4) = plt.subplots(ncols=4, sharey=False, figsize=(20,5)) | |
ax1.set_ylim([0,1]) | |
ax1.set_title(first) | |
sns.barplot(x='index', y='new_odds', data=counts1, ax=ax1) | |
ax2.set_ylim([0,1]) | |
ax2.set_title(second) | |
sns.barplot(x='index', y='new_odds', data=counts2, ax=ax2) | |
ax3.set_ylim([0,1]) | |
ax3.set_title(third) | |
sns.barplot(x='index', y='new_odds', data=counts3, ax=ax3) | |
ax4.set_ylim([0,1]) | |
ax4.set_title(fourth) | |
sns.barplot(x='index', y='new_odds', data=counts4, ax=ax4) | |
i_start += 4 | |
i_end += 4 | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment