Jan-01-2023, 07:44 PM
I've been playing around with it, and I got it to work for the most part, except there's a problem. I can filter data by EITHER country or year, but not both. If I hash out one variable, it works, but I can't figure out how to combine it:
Thanks!
country = [] while True: value = str(input('To filter data, enter a country, type "done" when done: ')) if value == 'done' : break try: value = str(value) except: print('Invalid input:') continue try: country.append(str(value)) except: country.append(value) print('you have entered: ',country) print(type(country)) year = [] while True: value = input('Enter a year, type "done" when done: ') if value == 'done' : break try: value = int(value) except: print('Invalid input:') continue try: year.append(int(value)) except: year.append(str(value)) print('you have entered:\n',year) # filter out rows without year & country olympics = name_country_year_event[name_country_year_event['Team'].isin(country) | name_country_year_event['Year'].isin(year)] # print csv print(olympics)Any ideas?
Thanks!