Looping 2 DataFrame Pandas I am learning about pandas and find an interesting case
i try to find total sales for every genre that exist in the data frame,I try looping a few time and get a dead end,maybe you can give me a few tips about this
here is my code
import pandas as pd


df = pd.read_csv('vgsales.csv')
dcheck = df.dtypes


#check value count in data frame
genre_values = df['Genre'].value_counts()

#check what value in dataframe
genre2 = df['Genre'].unique()

zero = 0

def multiply():
    while genre2['Racing'].isin(df['Genre']):
        df['Global_Sales'][0] + zero


result = multiply()
A simple group-by sum will solve your query:
df.groupby(['Genre'])['Global_Sales'].sum()