dataframe

#java

# 導包
import numpy as np
import pandas as pd
from pandas import Series,DataFrame

dic1={
    'name':['tom','jay','helly'],
    'age':[11,12,33],
    'classRoom':[1,2,3]
}  #數據源
df1=DataFrame(data=dic1)
df2=DataFrame(data=np.random.randint(60,100,size=(3,3)),
              index=['jay','tom','helly'],
             columns=['java','python','c']) #數據源
df1
df2
pd.merge(df1,df2,left_on='name',right_index=True) #合併
pd.merge(df2,df1,left_index=True,right_on='name')
df2.dtypes  #各個列的屬性
dataframe 合併
相關文章
相關標籤/搜索