投稿

2月 26, 2021の投稿を表示しています

turtle 多角形描画

イメージ
import turtle as t def takakkei(n,w): p=t.Pen() p.reset() p.up() p.goto(-25,-120) p.down() c=('red','green','pink','aqua','blue') deg=360//n for x in range(1,n+1): z=x%5 p.color(c[z]) p.forward(w) p.left(deg) t.setup(width=300,height=300) t.bgcolor("white") for i in range(3,16): takakkei(i,50) 実行結果 >>> === RESTART: C:/python/turtleDrawTakakkei.py === >>>

pandas csv入力 ピボット集計

import pandas as pd import os import numpy as np path=os.getcwd() print(path) def2=pd.read_csv('c:\python\sample2.csv') print(def2) table=pd.pivot_table(def2,values='price', index=['date'], columns=['item'],aggfunc=np.sum) print() print("ピボット集計 結果") print(table) ==== RESTART: C:/Users/ooshi/AppData/Local/Programs/Python/Python39/pandasCloss.py ==== C:\Users\ooshi\AppData\Local\Programs\Python\Python39 date item price 0 2015-01-01 apple 300 1 2015-01-01 apple 300 2 2015-01-01 orange 250 3 2015-01-02 orange 240 4 2015-01-02 orange 240 5 2015-01-02 banana 260 ピボット集計 結果 item apple banana orange date 2015-01-01 600.0 NaN 250.0 2015-01-02 NaN 260.0 480.0 >>>