2023年12月11日 星期一

Ch02 Pandas DataFrame 介紹 的整理與心得

# 匯入套件
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# 用字典形式來建立 DataFrame 
scores = {'Chinese':[100,80,90,70,100],
          'English':[70,90,80,100,90],
          'Math':[80,100,90,70,60]}
df = pd.DataFrame(scores)
print(df
#  在 DataFrame 加入索引
df.index = ['Jobs','Mary','Simon','Allen','Bob']
print(df)
 
#  印出 DataFrame 直行索引 
print(df.index)
#  印出 DataFrame 橫列索引
print(df.columns
#  印出 DataFrame 行列內的值 
print(df.values)  
#  印出 DataFrame 維度
print(df.shape)
#  印出 DataFrame 資料型態
print(df.dtypes)







沒有留言:

張貼留言

ZeroJudge python解答:s207. 找最大值、最小值與其出現的位置

  s207. 找最大值、最小值與其出現的位置 我的解答: n = int ( input ()) nlist = list ( map ( int , input (). split ())) maxn = max ( nlist ) minn = min ( ...