Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

python 3.x - Automatic "In" and "Out" functions in a Pandas Dataframe?

Just wondering if anyone knows if you can create functions and attach them to frame column type in Pandas so they are called automatically when you append or access data.

My scenario - I'm working with non-linear data Decibels, I would like to convert non-linear to a linear form so standard and existing python/pandas math can be used. For example, 80dB + 80dB is ~83.0103dB (-not 160dB).

So what I'm interested in if we can write the "in" and "out" functions and applying them to the column type (say "dB") so they are stored internally as linear data, 80dB = 100000000(in linear form). When you insert or append data the "in" function applied and the "out" function is applied to a dataframe when you access the data. This conversion becomes transparent and allows users to focus on value rather than remembering to do conversions.

Thoughts? Examples?

Much Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...