To make a dataframe out of two NumPy arrays in Python, you can use the pandas.DataFrame()
constructor. Here's an example:
main.py182 chars10 lines
In the above code, two NumPy arrays are initialized. Then, the pandas.DataFrame()
constructor is used with a dictionary to create a dataframe with two columns, 'Column1' and 'Column2', containing the values of array1
and array2
, respectively. The resulting dataframe is then printed to the console:
main.py91 chars6 lines
You can replace array1
and array2
with your own arrays in the code snippet above to create your own dataframe.
gistlibby LogSnag