熊猫学位日

pandas_degreedays的Python项目详细描述


欢迎使用熊猫的文档!

Latest VersionSupported Python versionsWheel formatLicenseDevelopment StatusDownloads monthlyDocumentation StatusSourcegraphGitterCode HealthBuild Status

大熊猫

熊猫学位日(pandas_degreedays)是 Python要计算的包degree days

使用量

必须提供Pandas Series 有温度值。

让我们调用ts_tempthis serie,它看起来像:

datetime
2014-03-20 23:00:00    11
2014-03-20 23:30:00    11
2014-03-21 00:00:00    11
2014-03-21 00:30:00    11
2014-03-21 01:00:00    11
2014-03-21 01:30:00    11
...
2014-11-01 20:00:00    12
2014-11-01 20:30:00    12
2014-11-01 21:00:00    12
2014-11-01 21:30:00    12
2014-11-01 22:00:00    12
2014-11-01 22:30:00    12
Name: temp, Length: 10757

您可以在sample文件夹中获得温度时间序列并读取 它使用:

import pandas as pd
filename = 'temperature_sample.xls'
df_temp = pd.read_excel(filename)
df_temp = df_temp.set_index('datetime')
ts_temp = df_temp['temp']

你也可以从 OpenWeatherMap.org。你需要 先安装 openweathermap_requests

import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
from pandas_degreedays.provider import TemperatureProvider
ts_temp = TemperatureProvider('OpenWeatherMap', api_key='').get_from_coordinates(0.34189, 46.5798114, '20120601', '20141215')

我们可以使用:

idx = ts_temp.index
s_idx = pd.Series(idx, index=idx)
diff_idx = s_idx-s_idx.shift(1)
s_sampling_period = diff_idx.value_counts()
sampling_period = s_sampling_period.index[0] # most prevalent sampling period
not_sampling_period = (diff_idx != sampling_period) # True / False

我们可以使用:

from pandas_degreedays import inter_lin_nan
ts_temp = inter_lin_nan(ts_temp, '1H') # interpolates linearly NaN

我们可以使用:

from pandas_degreedays import calculate_dd
df_degreedays = calculate_dd(ts_temp, method='pro', typ='heating', Tref=18.0, group='yearly')
method可以是:
-'pro'(能源专业人士)-这是默认计算 方法-'meteo'
typ(计算类型)可以是:
-'heating'-这是默认计算类型-'cooling'

Tref是参考温度-默认值是18.0

group可以是:
-'yearly'-这是默认的分组选项-'yearly10'- 与'yearly'相同,但年份开始于10月(10)-'monthly'- 'weekly'-None-任何可以使用的lambda函数 可应用于datetime
from pandas_degreedays import yearly_month
df_degreedays = calculate_dd(ts_temp, method='pro', typ='heating', Tref=18.0, group=lambda dt: yearly_month(dt, 10))

它输出一个Pandas DataFrame 学位日如下:

Tmin  Tmax   Tavg  Tref         DD      DD_cum
2014-03-22 7.0 11.0 9.00 18 9.000000 9.000000
2014-03-23 3.0 12.0 7.50 18 10.500000 19.500000
2014-03-24 0.0 10.0 5.00 18 13.000000 32.500000
2014-03-25 6.0 10.0 8.00 18 10.000000 42.500000
2014-03-26 5.0 12.0 8.50 18 9.500000 52.000000
2014-03-27 2.0 8.0 5.00 18 13.000000 65.000000
... ... ... ... ... ... ...
2014-10-26 5.0 17.0 11.00 18 7.000000 653.547663
2014-10-27 9.0 22.0 15.50 18 3.336923 656.884586
2014-10-28 7.5 20.0 13.75 18 4.544400 661.428986
2014-10-29 8.0 19.0 13.50 18 4.618182 666.047168
2014-10-30 12.0 22.0 17.00 18 1.992000 668.039168
2014-10-31 11.0 24.0 17.50 18 2.143077 670.182245

[224 rows x 6 columns]

您可以使用以下命令显示绘图:

from pandas_degreedays import plot_temp
plot_temp(ts_temp, df_degreedays)

关于熊猫

pandas是一个python包,它提供 快速、灵活和有表现力的数据结构 使用“关系”或“标记”数据既简单又直观。这是一个非常 方便的图书馆与时间序列工作。

安装

来自python包索引
$ pip install pandas_degreedays

源代码

使用git获取最新版本

$ git clone https://github.com/scls19fr/pandas_degreedays.git
$ cd pandas_degreedays
$ python setup.py install

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java IntelliJ找不到依赖项选项卡   java向字符串数组string[]添加元素并在Junit中测试结果   如何在eclipse中获取活动java项目的名称   如何使用java在mysql中插入时间   java ArrayList更新了插入一行,但Jtable仍然没有刷新   如何在JavaSwing中命名坐标(点)   java Matcher/模式不打印   java错误地设置了arraylist   使用UsernamePasswordCredential提供程序的java列表Azure AD   java在HTTP请求中设置UTC时间   未加载事件:jquery完整日历Java集成   java Maven插件依赖项无法从内部repo解析依赖项   Maven更新重置Java版本   java如何向中添加图片。带有Apache POI XWPF的docx,但不指定其大小   Java最大函数递归