What Is The Time Complexity Of .at And .loc In Pandas?
I'm looking for the time complexity of these methods as a function of the number of rows in a dataframe, n. Another way of asking this question is: Are indexes for dataframes in p
Solution 1:
Alright so it would appear that:
1) You can build your own index on a dataframe with .set_index in O(n) time where n is the number of rows in the dataframe
2) The index is lazily initialized and built (in O(n) time) the first time you try to access a row using that index. So accessing a row for the first time using that index takes O(n) time
3) All subsequent row access takes constant time.
So it looks like the indexes are hash tables and not btrees.
Post a Comment for "What Is The Time Complexity Of .at And .loc In Pandas?"