Last active
July 19, 2018 18:22
-
-
Save ringo156/0bdeeaa0598e124e9185f5355f6b4398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib.ticker as tick | |
df = pd.read_csv("./weatherdata/shigeto.csv", index_col='time') | |
sumPrecipitation = df['Precipitation'].sum() | |
print("期間内の総雨量 : " + str(sumPrecipitation)) | |
len = len(df.index) | |
max = 0 | |
max_old = 0 | |
time_s = 0 | |
time_o = 0 | |
for i in range(len-24): | |
max = df['Precipitation'][i:i+24].sum() | |
if(max > max_old): | |
max_old = max | |
time_s = df[i:i+1].index[0] | |
time_o = df[i+23:i+24].index[0] | |
print("24時間雨量が最大となるとき : ") | |
print(time_s) | |
print(time_o) | |
print(max_old) | |
df.index=pd.to_datetime(df.index,format='%Y/%m/%dT%H:%M:%S') | |
df_precipitation = df.iloc[:, [0]] | |
df_precipitation.plot.bar(figsize=(12,8),width = 0.8) | |
plt.ylabel("Precipitation[mm]") | |
ax = plt.gca() # get current axis | |
ax.xaxis.set_ticks_position("bottom") # 目盛りは軸の下 | |
ax.xaxis.set_major_locator(tick.MultipleLocator(6)) | |
plt.grid(which='major',color="#a9a9a9" ,linestyle='-', alpha = 0.7) | |
plt.tight_layout() | |
plt.savefig("test.png") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment