Use isin
for check membership:
df1["EU"] = np.where(df1["Country"].isin(EU), "EU", "Other")
print (df1)
Capital Country EU
0 Washington USA Other
1 Berlin Germany EU
2 Moscow Russia Other
3 Warsaw Poland EU
More Related Contents:
- Pandas conditional creation of a series/dataframe column
- Converting between datetime, Timestamp and datetime64
- What is the difference between size and count in pandas?
- Fast Haversine Approximation (Python/Pandas)
- Pandas Timedelta in Days
- Conditionally fill column values based on another columns value in pandas
- Calculate weighted average using a pandas/dataframe
- How to remove blanks/NA’s from dataframe and shift the values up
- Comparing previous row values in Pandas DataFrame
- selecting across multiple columns with python pandas?
- Ambiguity in Pandas Dataframe / Numpy Array “axis” definition
- Populate a Pandas SparseDataFrame from a SciPy Sparse Matrix
- Using numpy.genfromtxt to read a csv file with strings containing commas
- Counting unique values in a column in pandas dataframe like in Qlik?
- vectorize conditional assignment in pandas dataframe
- Create new dataframe in pandas with dynamic names also add new column
- How can I count the number of consecutive TRUEs in a DataFrame?
- Binning a column with pandas
- Convert numpy type to python
- Pandas Latitude-Longitude to distance between successive rows [duplicate]
- pd.Timestamp versus np.datetime64: are they interchangeable for selected uses?
- How to implode(reverse of pandas explode) based on a column
- Numpy isnan() fails on an array of floats (from pandas dataframe apply)
- Different std in pandas vs numpy
- Getting days since last occurence in Pandas DataFrame?
- Split Python sequence (time series/array) into subsequences with overlap
- Faster way to transform group with mean value in Pandas
- Add density curve on the histogram
- Bin values based on ranges with pandas [duplicate]
- Numpy.dtype has the wrong size, try recompiling