Unable to filter values in Python which has been imported as 'pandas.core.series.Series' datatype -


dataset: https://www.kaggle.com/rtatman/independence-days

i unable filter observations 'belgium' independence-day dataset.

below code:

import pandas pd path = filepath  #my hypothesis filtering country name not working since not string data type, hence tried converting 'str' while importing. readfile = pd.read_csv(path, dtype={'country': str}, engine = 'python')  df = pd.dataframe(readfile) columnnames = list(df.columns.values) df = pd.dataframe(readfile, columns = columnnames) print(type(df['country'])) countryname = 'belgium' df2 = df[df['country'] == countryname] print(df2)  output: empty dataframe columns: [country, date of holiday, year celebrated, event celebrated, name  of holiday] index: []  # tried data type conversion country column based on previous  #recommendation don't give me desired output.  #things tried.  1) df['country'].astype('str') 2) df['country'] = df['country'].astype(str)  data snippet |country     | date of holiday | year celebrated | event celebrated |name of holiday|  |afghanistan |08-19 august     |1919         |independence united kingdom in 1919.|afghan independence day| |algeria     |07-05 july       |1962         |independence france in 1962.        |independence day (algeria)| 

ps: new python stackoverflow. please assist.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -