title: How do I make my np.split end in an equal division?
body: <p>I am rehearsing to improve my skills on developing a game, using a reinforcement learning tutorial, but then I run into trouble making the np.split performing correctly (i.e. not resulting in an equal division). The code below shows the reward definition session, while defining the parameters of the environment in another py file. The following line then causes the problem displayed in the traceback info part.</p>
  <pre><code>rewards_per_thousand_episodes = np.split(np.array(rewards_all_episodes), num_episodes/1000)
  </code></pre>
  <p>Tried to look for a solution to the issue, yet in vain. Any suggestions to a solution will be highly appreciated...;o)</p>
  <p>Env definition:</p>
  <pre><code>import numpy as np
  import gym
  import random
  import time
  from IPython.display import clear_output
  
  env = gym.make(&quot;FrozenLake-v1&quot;)
  env.reset()
  
  # Construct Q-table, and initialize all the Q-values to zero for each state-action pair
  
  action_space_size = env.action_space.n
  state_space_size = env.observation_space.n
  
  q_table = np.zeros((state_space_size, action_space_size))
  
  print(&quot;\nq_table&quot;)
  print(q_table)
  
  # Initializing Q-Learning Parameters
  
  num_episodes = 10000 # total number of episodes the agent is to play during training
  max_steps_per_episode = 100 # maximum number of steps that agent is allowed to take within a single episode
  
  learning_rate = 0.1
  discount_rate = 0.99
  
  exploration_rate = 1
  max_exploration_rate = 1 # bounds to how small exploration rate can be
  min_exploration_rate = 0.01 # bounds to how large exploration rate can be
  
  # rate at which the exploration_rate will decay
  # LR changed to 0.001 due to inconsistencies in results with larger rate - https://youtu.be/HGeI30uATws?t=57
  exploration_decay_rate = 0.001
  </code></pre>
  <p>Reward definition:</p>
  <pre><code>import numpy as np
  import random
  from .... import \
      num_episodes, env, max_steps_per_episode, q_table, learning_rate, exploration_rate, discount_rate, \
      min_exploration_rate, max_exploration_rate, exploration_decay_rate
  
  rewards_all_episodes = []
  
  # Q-learning algorithm
  for episode in range(num_episodes):
      state = env.reset()
  
      # Exploration/exploitation trade-off
      done = False
      rewards_current_episode = 0
  
      for step in range(max_steps_per_episode):
  
  
          exploration_rate_threshold = random.uniform(0,1)
          if exploration_rate_threshold &gt; exploration_rate:
              action = np.argmax(q_table[state,:])
          else:
              action = env.action_space.sample()
  
          new_state, reward, done, info = env.step(action)
  
          #Update Q-table for Q(s,a)
          q_table[state, action] = \
              q_table[state, action] * (1 - learning_rate) + learning_rate * (reward + discount_rate *
                                                                              np.max(q_table[new_state, :]))
  
          state = new_state
          rewards_current_episode +- reward
  
          if done == True:
              break
  
          # Exploration rate decay - exploration rate update - https://youtu.be/HGeI30uATws?t=298
          exploration_rate = min_exploration_rate + (max_exploration_rate - min_exploration_rate) * np.exp(
              -exploration_decay_rate * episode)
  
          rewards_all_episodes.append(rewards_current_episode)
  
  rewards_per_thousand_episodes = np.split(np.array(rewards_all_episodes), num_episodes/1000)
  count = 1000
  print(&quot;\n********Average reward per thousand episodes********&quot;)
  for r in rewards_per_thousand_episodes:
      print(count, &quot;: &quot;, str(sum(r/1000)))
      count += 1000
  
  print(&quot;\n********Updated Q-table********&quot;)
  print(q_table)
  </code></pre>
  <p>Traceback info:</p>
  <pre><code>Traceback (most recent call last):
  File &quot;C:\Users\jcst\PycharmProjects\...\_test_Q_learning_and_Gym_run.py&quot;, line 48, in &lt;module&gt;
  rewards_per_thousand_episodes = np.split(np.array(rewards_all_episodes), num_episodes/1000)
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 5, in split
  File &quot;C:\Users\jcst\PycharmProjects\Python_3_9_test\venv\lib\site-packages\numpy\lib\shape_base.py&quot;, line 872, in split
  raise ValueError(
  ValueError: array split does not result in an equal division
  </code></pre>