ACCESS PANDAS DATAFRAMES AND NUMPY ARRAYS WITH THE STATA–PYTHON API


  • In the Data class, the fromNPArray() function loads a NumPy array into Stata‘s memory, and the toNPArray() function exports values from the current Stata dataset into a NumPy array.
  • In the Data class, the fromPDataFrame() function loads a pandas DataFrame into Stata‘s memory, and the toPDataFrame() function exports values from the current Stata dataset into a pandas DataFrame.
  • In the Frame class, the fromNPArray() function loads a NumPy array into a Stata frame, and the toNPArray() function exports values from a Stata frame into a NumPy array.

© Copyright 1996–2026 StataCorp LLC. All rights reserved.

  • In the Frame class, the fromPDataFrame() function loads a pandas DataFrame into a Stata frame, and the toPDataFrame() function exports values from a Stata frame into a pandas DataFrame.
  • In the Mata class, the fromNPArray() function stores a NumPy array as a Mata matrix, and the toNPArray() function exports a Mata matrix into a NumPy array.
  • In the Matrix class, the fromNPArray() function stores a NumPy array as a Stata matrix, and the toNPArray() function exports a Stata matrix into a NumPy array.