Nov-24-2023, 04:45 PM
I'm trying to learn how to use Pandas to manipulate csv's and excel files.
One thing I'm trying to do is read a list of colors from a csv list, then ask the user for a color input.
Then I want to compare the user input to the data read from the color csv list.
The problem I have is when I type in a color I know that is on the list, like say "Aqua" or "Yellow" for example, I will get the message "This value is not on the list."
Is there some sort of type conversion or other comparison I need to be doing?
Code for reference.
One thing I'm trying to do is read a list of colors from a csv list, then ask the user for a color input.
Then I want to compare the user input to the data read from the color csv list.
The problem I have is when I type in a color I know that is on the list, like say "Aqua" or "Yellow" for example, I will get the message "This value is not on the list."
Is there some sort of type conversion or other comparison I need to be doing?
Code for reference.
import pandas as pd
df = pd.read_csv('color_list_csv.csv', header = None)
print(df)
User_Color_Input = input("Please enter a Color: ")
if 'User_Color_Input' in df.values :
print("\nThis value exists in Dataframe")
else :
print("\nThis value does not exist in Dataframe")
df.to_excel('color_list_output.xlsx', index = False)This is the color list I'm using for reference, its a single column in csv file.