Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

change value in column based on other column value pandas code example

Example: change column value based on another column pandas

# Changes the 'is_electric' column based on value in the 'type' column
# If the 'type' column == 'electric' then the 'is_electric' becomes 'YES'
df['is_electric']= df['type'].apply(lambda x: 'YES' if (x == 'electric') else 'NO')

Tags:

Python Example

Related

for loop jinja template code example Post::create laravel code example how to print the putput of a matrix in tensorflow code example python time module functions code example nestjs ormconfigjs code example map de map golang code example how does nosql work code example ts node typescript nodejs app code example check if a string contains substring in sql code example mongo create admin code example bootstrap 3 center image vertically code example java sum digits of number code example

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy