Comparing two data frames in python

0

Good evening, gentlemen.

I'm new to python, and programming. I'm trying to compare two different data frames, each one with the data of cars of a specific year. For now I've done the following:

year_08 = np.repeat('2008', 1061) # Variável com a quantidade de linhas do dataframe de 2008
year_18 = np.repeat('2018', 832) # Variável com a quantidade de linhas do dataframe de 2018

df_08['year'] = year_08 # Criando uma nova coluna com o ano no dataframe de 2008
df_18['year'] = year_18 # Criando uma nova coluna com o ano no dataframe de 2018

df = df_08.append(df_18, ignore_index=True) # Juntando os dois dataframes

I also saw the increase from year to year with the following:

fuel01 = df
fuel01 = fuel01[fuel01.fuel != 'Gasoline'] # Exclui as linhas que tem 'Gasoline' como dado
fuel01['year'].value_counts()

I just did not like the way it was, I wanted something, let's say, more professional. Any ideas how to do it?

Thank you.

    
asked by anonymous 02.02.2018 / 21:02

0 answers