Horje
add a value to an existing field in pandas dataframe after checking conditions Code Example
add a value to an existing field in pandas dataframe after checking conditions
# Create a new column called based on the value of another column
# np.where assigns True if gapminder.lifeExp>=50 
gapminder['lifeExp_ind'] = np.where(gapminder.lifeExp >= 50, True, False)
gapminder.head(n=3)
add a value to an existing field in pandas dataframe after checking conditions
gapminder['gdpPercap_ind'] = gapminder.gdpPercap.apply(lambda x: 1 if x >= 1000 else 0)
gapminder.head()




Python

Related
gnome-shell turn off Code Example gnome-shell turn off Code Example
calcutalte average python Code Example calcutalte average python Code Example
how to subtract dates in Python Code Example how to subtract dates in Python Code Example
python arguments Code Example python arguments Code Example
unable to get local issuer certificate python Code Example unable to get local issuer certificate python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7