Skip to content

Instantly share code, notes, and snippets.

Avatar

Ichiru Kiyota kotoripiyopiyo

View GitHub Profile
View gist:9b2a66c8f485e25d405a6b98f3ef66a2
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
tokyo_tower = Image.open("tokyo_tower.png")
tower_color = np.array(tokyo_tower)
rgbcolor = ["red", "green", "blue"]
rgb_list = [0] * 3
for i in range(3):
rgb0, rgb1 = np.histogram(tower_color[:, :, i].flatten(), bins=256)
@kotoripiyopiyo
kotoripiyopiyo / gist:e6fdc515e5f4aa09e65afc0619182ced
Created Jul 13, 2020
何がなんでもfor文を使ってみる[Phthon勉強中]
View gist:e6fdc515e5f4aa09e65afc0619182ced
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
#画像の読み込み
rocket_org = Image.open("H2A.jpg")
#画像をndarrayに変換
rocket_org_array = np.array(rocket_org)
@kotoripiyopiyo
kotoripiyopiyo / gist:37d182947a0c234b0666f361a2dc28de
Created Jul 13, 2020
何がなんでもfor文を使ってみる[Phthon勉強中] 2
View gist:37d182947a0c234b0666f361a2dc28de
#ライブラリのインポートなど
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
#画像の読み込み
rocket_org = Image.open("H2A.jpg")
#画像をndarrayに変換
@kotoripiyopiyo
kotoripiyopiyo / gist:60842cbd95b52cbe94e5de74fc81e455
Created Jul 13, 2020
[記念メモ]はじめて自分で考えて書いたPythonコード
View gist:60842cbd95b52cbe94e5de74fc81e455
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
i=0
x=np.arange(1,11)
y=np.zeros(10)
while i <=9:
y[i]=np.random.uniform(1,10)
i +=1
plt.plot(x,y)
View gist:040b06ba19b20a9498c5f9f3820bd34e
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
tokyo_tower = Image.open("tokyo_tower.png")
tower_color = np.array(tokyo_tower)
hist_r, bins_r = np.histogram(tower_color[:, :, 0].flatten(), bins=256)
hist_g, bins_g = np.histogram(tower_color[:, :, 1].flatten(), bins=256)
hist_b, bins_b = np.histogram(tower_color[:, :, 2].flatten(), bins=256)
plt.figure(figsize=(10, 3))
@kotoripiyopiyo
kotoripiyopiyo / gist:ad5cc68ce5d47fb43982021b54441482
Created Jul 13, 2020
【Python勉強中】for文の訓練2
View gist:ad5cc68ce5d47fb43982021b54441482
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
tokyo_tower = Image.open("tokyo_tower.png")
tower_color = np.array(tokyo_tower)
rgb = [0] * 6
j = 0
for i in range(0, 5, 2):
rgb[i], rgb[i+1] = np.histogram(tower_color[:, :, j].flatten(), bins=256)
@kotoripiyopiyo
kotoripiyopiyo / gist:4737bc4c3235a319ab1c0cb29aafbe91
Created Jul 13, 2020
【Python】コロナの曜日別の東京の患者数をグラフに出してみた(挫折に挫折を繰り返した妥協の産物として)
View gist:4737bc4c3235a319ab1c0cb29aafbe91
#ライブラリ読み込み
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import japanize_matplotlib
#日付記述を日付データとしてcsv読み込む
covid_data = pd.read_csv("(都合によりURLのあちこちにスペース入ってるけど、使う時はスペース除いてください)https:// stopcovid19. metro. tokyo. lg. jp/ data/ 130001_tokyo_covid19_patients. csv", index_col="公表_年月日", parse_dates=True)
@kotoripiyopiyo
kotoripiyopiyo / gist:145bf40b9efe596ea2c0da34ec252573
Created Jul 13, 2020
とうとうPythonで「新型コロナの曜日別の年代ごと陽性者数」を出すことに成功
View gist:145bf40b9efe596ea2c0da34ec252573
###ライブラリ読み込み
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import japanize_matplotlib
###csv読み込む
covid_data = pd.read_csv("(都合によりURLのあちこちにスペース入ってるけど、使う時はスペース除いてください)https:// stopcovid19. metro. tokyo. lg. jp/ data/ 130001_tokyo_covid19_patients. csv", index_col="公表_年月日", parse_dates=True)
@kotoripiyopiyo
kotoripiyopiyo / gist:b12c191a4d09649f726b045bafbf8a81
Created Jul 13, 2020
[Pythonで機械学習]日本の人口推移の予測というのをやってみた
View gist:b12c191a4d09649f726b045bafbf8a81
#必要なライブラリのインポート
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
%matplotlib inline
#ファイル読み込み
df = pd.read_csv("downloaded_japan_population_utf8.csv")
View gist:64598757885cae50537d870d424198d1
#ダメな例
h = 0
i = str(0)
j = 11
while j != 10:
number = float(str(10.5) + (i * h) + str(1))
rounding = round(number)
print(str(number) + ' is ' + str(rounding))
h += 1