You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add constant time Series/Dataframe.count(), trivial implementations of iloc(integer) #176
count requires O(N) and at(offset) - the most frequent type of index - does hashmap lookups.
consider an O(N) for loop becomes O(N^2) and the performance of this sort of loop could have.... The random places in practice one needs the shape of a dataframe are high and shouldn't incur computation or heavy operations.
function visitEveryRow( visitor )
for(let i = 0; i < df.count(); ++i){
visitor(df.iloc[i])
}
changed the title [-]add constant time Series/Dataframe.count(), trivial implementations of iat(integer)[/-][+]add constant time Series/Dataframe.count(), trivial implementations of iloc(integer)[/+]on Dec 26, 2024
I think one thing that needs evaluation is remove allowing deferred values for construction which is something for instance pandas doesn't do and which is satisfiable by another strategy which is user holding a promise around a dataframe / using an async expression , not having the dataframe deal with that internally. This would remove the checking for deferred values inside the dataframe and allow the trivial implementations above which optimize out well and simplify + optimize to the common case. Wdyt?
I think it could be a good idea, but I'm worried removing something could break existing code. I suppose you could implement it so that the deferred values are evaluated immediately - would that still result in the desired simplification?
Sounds like it shouldn't be too hard. Do you want to try it and submit a PR? For the first step (evaluating the lazy argument in the constructor) shouldn't require any new tests... just need to keep existing tests passing and try to make sure the interface to the user is the same.
Activity
[-]add constant time Series/Dataframe.count(), trivial implementations of iat(integer)[/-][+]add constant time Series/Dataframe.count(), trivial implementations of iloc(integer)[/+]ashleydavis commentedon Dec 29, 2024
@nevion thanks for you feedback. Are you able to propose a solution?
nevion commentedon Dec 29, 2024
return this.getContent().values.length, similiar for Series.
iloc(index: number) : this.getContent().values[index]
also noticed dtypes aren't stored as part of the context - these should be preserved for 0 length data frames
ashleydavis commentedon Jan 2, 2025
Thanks @nevion, are you up for getting that in a PR?
nevion commentedon Jan 2, 2025
I think one thing that needs evaluation is remove allowing deferred values for construction which is something for instance pandas doesn't do and which is satisfiable by another strategy which is user holding a promise around a dataframe / using an async expression , not having the dataframe deal with that internally. This would remove the checking for deferred values inside the dataframe and allow the trivial implementations above which optimize out well and simplify + optimize to the common case. Wdyt?
ashleydavis commentedon Jan 2, 2025
I think it could be a good idea, but I'm worried removing something could break existing code. I suppose you could implement it so that the deferred values are evaluated immediately - would that still result in the desired simplification?
nevion commentedon Jan 2, 2025
yea I think so, test if it's a generator vs an array and if generator eval in constructor
ashleydavis commentedon Jan 2, 2025
Sounds like it shouldn't be too hard. Do you want to try it and submit a PR? For the first step (evaluating the lazy argument in the constructor) shouldn't require any new tests... just need to keep existing tests passing and try to make sure the interface to the user is the same.
No hurry though... take your time with it.