Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Pandas data discretization

Shulou Source: shulou.com Published: 2022-06-03 19:30:50 09月15日 Update

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!

Tags: Data discretization grouping attributes examples analysis number content interval articles ranges tools integers stocks learning help statistics different robust representative Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple MariaDB Shulou Tech Info Docker