What is the Big O Complexity of Reversing the Order of Columns in Pandas DataFrame?

I don’t know how Pandas implements this, but I did test it empirically. I ran the following code (in a Jupyter notebook) to test the speed of the operation: def get_dummy_df(n): return pd.DataFrame({‘a’: [1,2]*n, ‘b’: [4,5]*n, ‘c’: [7,8]*n}) df = get_dummy_df(100) print df.shape %timeit df_r = df[df.columns[::-1]] df = get_dummy_df(1000) print df.shape %timeit df_r = … Read more

Calculating phi(k) for 1

This can be done with Memory complexity O(Sqrt(N)) and CPU complexity O(N * Log(Log(N))) with an optimized windowed Sieve of Eratosthenes, as implemented in the code example below. As no language was specified and as I do not know Python, I have implemented it in VB.net, however I can convert it to C# if you … Read more