Python Forum
How to add an element such as an average to a multi-dimensional array?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add an element such as an average to a multi-dimensional array?
#7
(Jan-06-2019, 09:35 PM)Gribouillis Wrote:
xhughesey Wrote:So I guess my question would be; How can I pull something from the end of multiple arrays with the same starting integer and put that result into an array?
The question is surprising because it looks like something that is much easier than the rest of the code in the git repo. Why not
 games = [ [5, -1, 7, -8, 3, "bot wins"], [5, -1, 3, -8, 7, "bot wins"], [5, -2, 4, -1, 6, "bot wins"], [5, -1, 7, -2, 3, -3, "bot loses"],] wons = sum(x[-1] == 'bot wins' for g in games) result = [1, 5, wons/len(games)] 

That was my fault. I was kind of asking myself then I was going to answer myself on here. I figured it out and implemented it. I just haven't committed it yet. Thanks a lot though I was thinking way to hard about the previous question.
Reply


Messages In This Thread
RE: How to add an element such as an average to a multi-dimensional array? - by xhughesey - Jan-06-2019, 10:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  RandomForest --ValueError: setting an array element with a sequence JaneTan 0 1,743 Sep-08-2021, 02:12 AM
Last Post: JaneTan
  I am trying to change the value of an element in a record array ingu 1 2,192 Jan-14-2020, 01:30 PM
Last Post: perfringo
  TensorFlow get error - array with more than one element is ambiguous vokoyo 3 5,564 Nov-07-2019, 01:12 PM
Last Post: ThomasL
  How convert multidimensional array to two dimensional array tkkhan44 1 2,776 Feb-20-2019, 05:00 AM
Last Post: scidam
  Three-dimensional Contour Plots minifizikus 1 3,277 Sep-13-2018, 10:56 PM
Last Post: Larz60+
  Convert element of list to integer(Two dimentional array) zorro_phu 3 4,766 Jun-12-2018, 04:49 AM
Last Post: zorro_phu
  2 Dimensional NumPy for beginners Jack_Sparrow 2 3,117 May-08-2018, 05:21 PM
Last Post: killerrex
  Recurse through n-dimensional array ColdDeath 2 2,987 Apr-05-2018, 11:20 AM
Last Post: KenniT
  ValueError: The truth value of an array with more than one element is ambiguous. Eliza5 1 14,351 Apr-02-2018, 12:03 AM
Last Post: scidam
  Two Dimensional Chart from CSV File srini1995 0 2,236 Nov-27-2017, 07:10 AM
Last Post: srini1995

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020