Answers for "create a new column in pandas and assign value with conditions"

3

Add new column based on condition on some other column in pandas.

# np.where(condition, value if condition is true, value if condition is false)

df['hasimage'] = np.where(df['photos']!= '[]', True, False)
df.head()
Posted by: Guest on August-08-2021
0

how to assign a new value in a column in pandas dataframe

df = df.assign(industry='yyy')
Posted by: Guest on September-21-2020

Code answers related to "create a new column in pandas and assign value with conditions"

Python Answers by Framework

Browse Popular Code Answers by Language