memoryfm.weighted_attachment#
- memoryfm.weighted_attachment(sclog, by='track', freq='W', year=None, alpha=1)#
Calculate weighted attachment index.
The Weights are given by
log2(1+r), where r is the ratio of scrobbles in a period and maximum number of scrobbles in all periods for the frequency.- Parameters:
- sclogScrobbleLog
a memoryfm ScrobbleLog
- bytrack, artist, album
The field to use for calculating the weighted Attachment Index.
- freqstr, pd.Period
The time frequency to use for the weighted attachment index. For instance, “2W” means a attachment index is calculated bi-weekly i.e. one value for every two weeks. For a full description, see pandas period aliases
- yearint, Optional
The year to use for filtering. If
Noneor not passed, no filtering is done.- alphanp.float64
A positive floating point value, representing the order of Attachment Index.
- Returns:
- pd.Series
Returns a pandas Series containing weighted Attachment Index for each period.