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

Example Analysis of Pandas data discretization

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you the "sample analysis of Pandas data discretization", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn the article "sample analysis of Pandas data discretization".

Why discretization?

The purpose of continuous attribute discretization is to simplify the data structure. Data discretization technology can be used to reduce the number of given continuous attribute values. Discretization method is often used as a tool for data mining.

Throwing away some information can make the model more robust and have stronger generalization ability.

What is the discretization of data

The discretization of continuous attributes is to divide the range of continuous attributes into several discrete intervals, and finally use different symbols or integer values to represent the attribute values that fall in each sub-interval.

Separate box

Case

1. First read the stock data and filter out the p_change data

Data = pd.read_csv (". / data/stock_day.csv") pairchange= data ['pairchange']

two。 Grouping stock rise and fall data

Tools used:

Pd.qcut (data, bins)-isobaric sub-box:

Grouping data groups will generally be used in conjunction with value_counts to count the number of each group

Series.value_counts (): count the number of grouping

# self-grouping qcut = pd.qcut (p_change, 10) # calculate the number of data allocated to each group qcut.value_counts ()

Pd.cut (data, bins)-equal width box:

# specify grouping interval bins = [- 100,7,-5,-3,0,3,5,7100] p_counts = pd.cut (p_change, bins)

The above is all the contents of the article "sample Analysis of Pandas data discretization". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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