Python Forum
how do I return Max Test result + corresponding student name from an excel dataset?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I return Max Test result + corresponding student name from an excel dataset?
#1
I have a dataset with column headers Student name, ID, Nationality and several test scores (one col per subject.) I have converted the columns to list and am able to get the max score but not sure as to how I can get the max test score for a subject + the students name. Thanks in advance!
Reply
#2
Two things. First, as always in this site, show us your code, what you have done so far!
Second, we need to know the format of the data. You say a list, how is that formatted? A list of what? You also mention a dataset. Pandas (I hope)?
Reply
#3
(Jan-16-2022, 04:52 PM)jefsummers Wrote: Two things. First, as always in this site, show us your code, what you have done so far!
Second, we need to know the format of the data. You say a list, how is that formatted? A list of what? You also mention a dataset. Pandas (I hope)?

yes in pandas, converted the excel file to list using pandas as pd
Reply
#4
You should follow jefsummers advice.
(Jan-16-2022, 04:52 PM)jefsummers Wrote: show us your code, what you have done so far!
sean1 Wrote:yes in pandas, converted the excel file to list using pandas as pd
It should no be converted a list,maybe you mean DataFrame?
import pandas as pd

df = df.to_excel('file_name.xlsx', index=False)

Ok to show a example that can help,as you see it easy to make example code that other can run.
import pandas as pd
from io import StringIO

data = StringIO('''\
Movie,Year
The Godfather,1972
Seven,1995
Jaws,1975
Lawrence of Arabia,1962''')

df = pd.read_csv(data, sep=',')
# A DataFrame this is what all data that comes into Pandas become
>>> df
                Movie  Year
0       The Godfather  1972
1               Seven  1995
2                Jaws  1975
3  Lawrence of Arabia  1962
>>> 
>>> year_max = df['Year']
>>> year_max.max()
1995
>>> 
>>> # To get max value and whole row
>>> year = df[df['Year']==df['Year'].max()]
>>> year
   Movie  Year
1  Seven  1995
sean1 likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  This result object does not return rows. It has been closed automatically dawid294 5 676 Jan-10-2024, 10:55 PM
Last Post: deanhystad
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 3,064 Jul-03-2021, 10:07 AM
Last Post: Anldra12
  How do I split a dataset into test/train/validation according to a particular group? 69195Student 1 2,241 May-12-2021, 08:27 PM
Last Post: bowlofred
  Generate questions from excel to test my chatbot mcubac08 5 2,827 Sep-01-2020, 06:15 PM
Last Post: mcubac08
  How to write test cases for a init function by Unit test in python? binhduonggttn 2 3,062 Feb-24-2020, 12:06 PM
Last Post: Larz60+
  How to write test cases by Unit test for database configuration file? binhduonggttn 0 2,511 Feb-18-2020, 08:03 AM
Last Post: binhduonggttn
  test pattern and add result in a table sam1975 1 1,867 Mar-05-2019, 02:41 PM
Last Post: sam1975
  python code (embedded in Redshift) to return result of the query Mel 0 2,408 Aug-24-2018, 06:12 PM
Last Post: Mel
  Multiple "return" statements or "result" variable? WolfWayfarer 7 7,674 Jul-25-2018, 07:51 AM
Last Post: perfringo
  get specific items from result return info mamoman 3 3,053 Jul-22-2018, 12:46 PM
Last Post: mamoman

Forum Jump:

User Panel Messages

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