Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help creating a histogram using an array
Hey, so I'm currently struggling on a piece of code. I'm not very proficient at Python so bear with me. What I have is a numpy array of baseball statistics with 20 columns and a lot of rows and two of the columns are the year the stats were taken from and a unique player id that only applies to this one person. As some players returned for more than a year, some of the player ids repeat in later rows. There is also a column with the number of runs that player got in a year.

What I'm trying to accomplish with this is make a histogram where the x axis is total number of runs a player got and the y axis is number of players who got these many runs, with 100 bins.

I used np.unique to make an array with the player ids only listed once and I know I need some weird kind of for loop to add all the runs to the player id, then I probably need an array with 2 columns, being the id and the runs gotten by that id, and a where statement to get the number of players with a certain amount of runs within a range to then be graphed.

Any help is appreciated. Thanks!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to fit a 2D histogram like in ROOT? Zandar 2 717 Aug-06-2019, 03:01 PM
Last Post: Zandar
  while creating a array using numpy.arrange, how to negate only the last 50 numbers? vicky53 1 592 Apr-06-2019, 11:52 AM
Last Post: scidam
  creating an empty NumPy array in Python sandeepatel 2 1,924 Jan-16-2019, 09:24 AM
Last Post: rinu
  histogram error alyssaantarctica 1 803 Jul-09-2018, 10:46 PM
Last Post: Larz60+
  histogram with matplotlib vaugirard 10 1,805 Jun-01-2018, 04:13 AM
Last Post: vaugirard
  Histogram help dandatadan 1 880 Nov-25-2017, 06:07 AM
Last Post: heiner55
  plotting histogram vvv 1 1,438 Mar-10-2017, 11:47 PM
Last Post: zivoni
  Creating 2D array without Numpy landlord1984 3 17,240 Jan-28-2017, 01:34 AM
Last Post: ichabod801

Forum Jump:

Users browsing this thread: 1 Guest(s)