Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to select rows in Pandas data box in Python

2025-03-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the Python Pandas data box how to select rows, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Description

1. Boolean index (df [df ['col'] = = value])

2. Location index (df.iloc [...])

3. Tag index (df.xs (...))

4. Df.query (...) Application program interface

Each example and suggestions for when to use certain technologies are shown below. Let's assume that our standard is column 'Awareness Foo'.

(note about performance: for each basic type, we can keep it simple by using Pandas API, or we can take risks outside of API, usually into NumPy, and speed up. )

Set up

The first thing we need to do is to determine a condition that will be used as our criteria for selecting rows. We will start with the case of OP column_name = = some_value and include some other common use cases.

Borrow @ unutbu:

Import pandas as pd, numpy as npdf = pd.DataFrame ({'Aging:' foo bar foo bar foo bar foo foo'.split (), 'dating:' one one two three two two one three'.split (), 'dating: np.arange (8),' dating: np.arange (8) * 2}) Thank you for reading this article carefully I hope the article "how to choose rows in Pandas data boxes in Python" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report