To construct DataFrame more effectively

The old code of python looks like:

This snippet above will cost 7 seconds to run on my laptop.
Actually, pd.concat() is an expensive operation for CPU. So let’s replace it with common python dictionary:

This snippet only costs 0.03 seconds, which is more effective.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.