简体   繁体   中英

Pandas Dataframe Indexing, Where

So I have a dataframe of wine data

wines_dict = {
'Appellation': list(wine_appellations),
'Ratings': list(wine_ratings),
'Region': list(wine_regions),
'Name': list(wine_names),
'Varietal': list(wine_varietals),
'WineType': list(wine_wine_types),
'RetailPrice': list(wine_retail_prices) 
}

wines_df = pd.DataFrame(
data = wines_dict,
columns =[
    'Region',
    'Ratings',
    'Appellation',
    'Name',
    'Varietal',
    'WineType',
    'RetailPrice'
    ]
)

I am trying to slice it using wines_df.where((wines_df['Ratings'] > 95) & (~pd.isnull(wines_df['Ratings']))) but it is returning back NaN ratings still.

0          NaN
1          NaN
2          NaN
3          NaN
4         97.0
5         98.0
6          NaN

How can i slice it so that it returns all the Non Null values that are greater than 95?

像这样的简单切片将为您提供所需的输出

wines_df[(wines_df['Ratings'] > 95) & (wines_df['Ratings'].notnull())]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM