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

Python analyzes how to use qcut in a package

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use qcut in Python analysis package". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use qcut in the Python analysis package.

Its function is to determine the interval of boxes according to the frequency of the value, so as to satisfy the equal number of samples in each box as much as possible.

Let's look at the example first:

Ages = np.array ([5, 10, 36, 36, 12, 77, 89, 100, 30, 1]) # Age data pd.qcut (ages, 3, labels= ['green', 'middle', 'old']). Value_counts ()

# results: green No. 3 Middle School No. 3 Old 3dtype: int64

As you can see, the number of samples in each interval is 3. 5%. However, the lengths of the three intervals obtained by qcut are not necessarily equal. This is the biggest difference from cut, which is divided into equal intervals by cut.

# these are the three intervals obtained after qcut:

Categories (3, interval [float64]): [(0.999, 11.333] < (11.333, 49.667] < (49.667, 100.0)]

Obviously, the length of the interval is different.

At this point, I believe you have a deeper understanding of "how to use qcut in the Python analysis package". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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

Internet Technology

Wechat

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

12
Report