“Buat Pandas DataFrame” Kode Jawaban

cara membuat basis data dalam python

import pandas as pd
  
# intialise data of lists.
data = {'Name':['Tom', 'nick', 'krish', 'jack'],
        'Age':[20, 21, 19, 18]}
  
# Create DataFrame
df = pd.DataFrame(data)
  
# Print the output.
df
silexxx

Creator Daframe Python

d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)
df
Awful Alpaca

Buat Python DataFrame

import numpy as np
import pandas as pd
vect1=np.zeros(10)
vect2=np.ones(10)
df=pd.DataFrame({'col1':vect1,'col2':vect2})
Tremendous Enceladus

DataFrame Buat

>>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
...                    columns=['a', 'b', 'c'])
>>> df2
   a  b  c
0  1  2  3
1  4  5  6
2  7  8  9
Difficult Dunlin

Cara membuat DataFrames

import pandas as pd
data = {
	"A":[1,2,3],
    "B":[4,5,6],
    "C":[7,8,9]
}
index = [1,2,3,4,5,6,7,8,9]

pd.DataFrame(data=data, index=index)
Courageous Crane

Buat Pandas DataFrame

import pandas as pd

boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
         'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle']
        }
df = pd.DataFrame(boxes, columns = ['Color', 'Shape'])

print(df)
Fine Flamingo

Jawaban yang mirip dengan “Buat Pandas DataFrame”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya