Jupyter notebook. IndexingError: Unalloble boolean Series provided as an indexer (index of the boolean Series and of the indexed object do not match

0

I run Spyder correctly, the following script:

  # Selección de indicadores para paises de la CEE
def indicadores_CEE (indicator_code, indicator_name, year):
    df_ind_CEE = data[(data.CountryCode == "ESP") | (data.CountryCode == "PRT") | (data.CountryCode == "GBR") |
                      (data.CountryCode == "DEU") | (data.CountryCode == "ITA") | (data.CountryCode == "FRA")]
    # seleccionamos todas las filas en las que el año es >= 2004, y las columnas cuys etiquetas invocamos.
    df_aux_CEE = df_ind_CEE[(df_ind_CEE["Year"] >= ini_year) & (df_ind_CEE["Year"] <= end_year)]
    #year_select = df_aux['Year'] >= 2004

    df_aux_CEE = df_aux_CEE.loc[year_select,["CountryCode", "IndicatorCode", "Year", "Value"] ]
    # pivotamos
    df_analisis_piv_CEE = pd.pivot_table(df_aux_CEE, index=["Year"],columns = "CountryCode",values = "Value")
    df_analisis_piv_CEE.plot(figsize = (12,8));
    # Gráfica
    plt.xlabel('Year')
    plt.ylabel("GDP per capita")
    #label the figure
    plt.title(indicator_name)       

    return df_aux_CEE, df_analisis_piv

ini_year = 1975
end_year = 2014
indicator_code = "FP.CPI.TOTL.ZG"
indicator_name = "Inflation, consumer prices (annual %)"
indicator_country = "ESP"

df_aux_CEE, df_analisis_piv_CEE = indicadores_CEE (indicator_code, indicator_name, year)

However, when I run it on jupyter notebook, it returns the error:

  

IndexingError: Unalignable boolean Series provided as indexer (index   of the boolean Series and of the indexed object do not match

Other scripts developed in this same project, work well in both. The Python version is the same in both. At the beginning of the notebook I have% matplotlib inline. data is an import of a csv file (560845KB) What could be the problem?

    
asked by efueyo 17.07.2018 в 16:18
source

0 answers