def choose_action(self, observation):
    self.check_state_exist(observation)
    if (np.random.uniform() < self.epsilon):
        state_action = self.q_table.ix[observation, :]
        state_action = state_action.reindex(np.random.permutation(state_action.index))
        action = state_action.idxmax()
    else:
        action = np.random.choice(self.actions)
    return action
def choose_action(self, observation):
    self.check_state_exist(observation)
    if (np.random.uniform() < self.epsilon):
        state_action = self.q_table.ix[observation, :]
        state_action = state_action.reindex(np.random.permutation(state_action.index))
        action = state_action.idxmax()
    else:
        action = np.random.choice(self.actions)
    return action