mmyjh86

[PYSTOCK] DataFrame 생성 방법에 따른 속도 차이

Aug 25th, 2019
115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import numpy as np
  3. from pandas import DataFrame
  4.  
  5. data = np.random.rand(5000, 5000)
  6.  
  7. # Method1
  8. start_time = time.time()
  9. df = DataFrame(data)
  10. elapsed_time = time.time() - start_time
  11. print(elapsed_time)
  12.  
  13. # Method2
  14. start_time = time.time()
  15. df1 = DataFrame()
  16. for row in data:
  17.     df2 = DataFrame(row)
  18.     df1.append(df2)
  19.  
  20. elapsed_time = time.time() - start_time
  21. print(elapsed_time)
  22.  
  23. del data
RAW Paste Data