Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

How to Use where() in Numpy and Pandas (Python)

Автор: DataDaft

Загружено: 2020-09-11

Просмотров: 17731

Описание:

This video shows how to use the where() function in numpy and pandas to extract indices based on logical conditions and populate new columns of data based on elementwise logic. The np.where() function can perform a similar operation to the ifelse() function in R.

If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?su...


Code used in this Python Code Clip:

import numpy as np
import pandas as pd

import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset("mtcars", "datasets", cache=True).data

mtcars.head()

Extract indices that meet a condition
inds = np.where(mtcars.mpg > 22)

inds

Perform operations across an array or column based on a condition

np.where(mtcars.mpg > 22, # Condition
"High MPG", # Value to set if condition is True
"Low MPG") # Value to set if condition is False

Perform elementwise operations on an array or column

np.where(mtcars.mpg > 22, # Condition
mtcars.mpg, # Value to set if condition is True
mtcars.cyl) # Value to set if condition is False



Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .


⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_me...

How to Use where() in Numpy and Pandas (Python)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Как обнаружить и заполнить пропущенные значения в Pandas (Python)

Как обнаружить и заполнить пропущенные значения в Pandas (Python)

Search-and-replace Pandas values with

Search-and-replace Pandas values with "where" and "mask"

Python NumPy Tutorial for Beginners

Python NumPy Tutorial for Beginners

Полный курс Python NumPy для науки о данных за 30 минут | Полное руководство по NumPy Python

Полный курс Python NumPy для науки о данных за 30 минут | Полное руководство по NumPy Python

Вам следует поместить это во все ваши скрипты Python | if __name__ == '__main__': ...

Вам следует поместить это во все ваши скрипты Python | if __name__ == '__main__': ...

How To Use apply() In Pandas (Python)

How To Use apply() In Pandas (Python)

Python if __name__ == '__main__': наглядное объяснение

Python if __name__ == '__main__': наглядное объяснение

Исследовательский анализ данных с помощью Pandas Python

Исследовательский анализ данных с помощью Pandas Python

1000x faster data manipulation: vectorizing with Pandas and Numpy

1000x faster data manipulation: vectorizing with Pandas and Numpy

4 функции Pandas, о которых я хотел бы знать раньше

4 функции Pandas, о которых я хотел бы знать раньше

Python for Data Analysis: Exploring and Cleaning Data

Python for Data Analysis: Exploring and Cleaning Data

Как использовать map() в Pandas (Python)

Как использовать map() в Pandas (Python)

numpy.where() - Explained with examples

numpy.where() - Explained with examples

Pandas Where | pd.DataFrame.where()

Pandas Where | pd.DataFrame.where()

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Pandas Conditional Columns: Set Pandas Conditional Column Based on Values of Another Column

Pandas Conditional Columns: Set Pandas Conditional Column Based on Values of Another Column

NumPy Crash Course - Complete Tutorial

NumPy Crash Course - Complete Tutorial

Advanced Use of groupby(), aggregate, filter, transform, apply - Beginner Python Pandas Tutorial #5

Advanced Use of groupby(), aggregate, filter, transform, apply - Beginner Python Pandas Tutorial #5

Python Object Oriented Programming (OOP) - For Beginners

Python Object Oriented Programming (OOP) - For Beginners

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com