Hi, everyone.
Is there a way to store the number of element values that match a specific value in a specific column of DataFrame as variables?
You are trying to save Row numbers as variables and then try to store elements corresponding to the row values in different columns as different variables. I'd appreciate your help.
python
city = [Seoul, Busan, Daegu, Daejeon, Gwangju, Daejeon]
df = pd.DataFrame (columns = ['city'], index = range (len(city)))))
df['City'] = city
print(df)
print('-' * 10)
city in [Busan, Daejeon]:
cityIndex = df.index[df['city'] == city.tolist() #LISTTYPE
print(city, cityIndex)
© 2025 OneMinuteCode. All rights reserved.