Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert numpy array to dataframe

import numpy as np
import pandas as pd

my_array = np.array([[11,22,33],[44,55,66]])

df = pd.DataFrame(my_array, columns = ['Column_A','Column_B','Column_C'])

print(df)
print(type(df))
Comment

convert array to dataframe python

np.random.seed(123)
e = np.random.normal(size=10)  
dataframe=pd.DataFrame(e, columns=['a']) 
print (dataframe)
          a
0 -1.085631
1  0.997345
2  0.282978
3 -1.506295
4 -0.578600
5  1.651437
6 -2.426679
7 -0.428913
8  1.265936
9 -0.866740

e_dataframe=pd.DataFrame({'a':e}) 
print (e_dataframe)
          a
0 -1.085631
1  0.997345
2  0.282978
3 -1.506295
4 -0.578600
5  1.651437
6 -2.426679
7 -0.428913
8  1.265936
9 -0.866740
Comment

PREVIOUS NEXT
Code Example
Python :: python download file from web 
Python :: python search string for word 
Python :: drop na in pandas 
Python :: python install gimp 
Python :: get index of list item in loop 
Python :: remove turtle 
Python :: pygame.set_volume(2.0) max volume 
Python :: get cpu count in python 
Python :: python get filename without extension 
Python :: text size legend to bottom matplotlib 
Python :: python continue vs pass 
Python :: read_csv Unnamed: 0 
Python :: how to set icon in tkinter 
Python :: django queryset group by sum 
Python :: convert categorical data type to int in pandas 
Python :: download kaggle dataset in colab 
Python :: how to execute a cmd command in python 
Python :: Python find max in list of dict by value 
Python :: scikit learn split data set 
Python :: python not null 
Python :: creating virtual environment python 
Python :: pandas get column values distinct 
Python :: how to run python code on github 
Python :: python read text file look for string 
Python :: message tags in django 
Python :: car in programming python 
Python :: python logging to file 
Python :: how to create a database in python 
Python :: pyperclip 
Python :: python move directory 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =