0

I have a dataset from the last few years of about 20 esports teams who have all played each other a number of times. I'd like to be able to insert any pair of teams and have the program response be a list of their prior matchups, including who won and the date, if possible. Is this type of text-based "drop down menu" even possible in Python?

This is a mostly theoretical question at this point, as I want to make sure Python covers the scope of what I'm hoping to achieve before devoting more time to working it out. Any advice as to how I would start this project would be greatly appreciated. Thank you

  • *I have a dataset from the last few years of about 20 esports teams who have all played each other a number of times.* in what format? *text-based "drop down menu"* so you want text user interface XOR graphical user interface (GUI)? – Daweo May 07 '23 at 09:12

2 Answers2

0

You could handle this in a simple way via txt files that will be read from the program to show the info or you could use a database to store the data and make python connect to the database and make query trough mysql.connector library.

omostr
  • 1
  • 2
0

Assuming you have the data in a CSV file with columns such as: Date, Team 1, Team 2, Winner, Loser. You can use pandas to create a dataframe (table) and then for a 'list of their prior matchups' you can simply filter the dataframe for your output:

import pandas as pd
import numpy as np

df = pd.read_csv('filename.csv')

def get_prior_matchups(team1, team2):
    team1_matchups = df[(df['Team 1'] == team1) & (df['Team 2'] == team2)]
    team2_matchups = df[(df['Team 1'] == team2) & (df['Team 2'] == team1)]
    all_prior_matchups = pd.concat([team1_matchups, team2_matchups])

    if not all_prior_matchups.empty:
        matchups_list = []
        for index, row in all_prior_matchups.iterrows():
            date = row['Date']
            winner = row['Winner']
            loser = row['Loser']
            matchup_result = f"{winner} defeated {loser} on {date}"
            matchups_list.append(matchup_result)
        return matchups_list
    else:
        return "No prior matchups found"

print(get_prior_matchups('Team 1', 'Team 2'))

For a 'text-based drop down menu' I can think of two options:

  • You can use the tkinter module to create a GUI with a drop down menu like this.

  • Or you can use the curses module to create a text-based GUI menu on the terminal. I found this StackOverflow answer.

Ahmar
  • 584
  • 2
  • 7