相关疑难解决方法(0)

使用熊猫按天获取数据的累计和

蟒蛇

我从Wunderground获得了122天的天气数据,这些数据没有相等的时间采样间隔。这是我的数据示例:

Bangor Weather Data from Wunderground
Datetime,Temp(F),Precip(in.),Snow (in.),PET(in./day),Baro(mBar)
    2015-12-02 01:30:00,1.1,0.3,0.0,0.45524647117649564,1017.5 
    2015-12-02 01:53:00,1.1,0.3,0.0,0.45524647117649564,1017.6 
    2015-12-02 02:20:00,1.1,0.3,0.0,0.45524647117649564,1017.2 
    2015-12-02 02:53:00,1.7,0.5,0.0,0.500024812603692,1016.7 
    2015-12-02 02:55:00,1.7,0.3,0.0,0.500024812603692,1016.5 
    2015-12-02 03:09:00,1.1,0.3,0.0,0.45524647117649564,1016.1 
    2015-12-02 03:33:00,1.1,0.5,0.0,0.45524647117649564,1016.1 
    2015-12-02 03:53:00,1.7,0.8,0.0,0.500024812603692,1016.1 
    2015-12-02 04:34:00,1.7,0.5,0.0,0.500024812603692,1015.1 
    2015-12-02 04:46:00,1.7,0.5,0.0,0.500024812603692,1015.1 
    2015-12-02 04:53:00,1.7,0.8,0.0,0.500024812603692,1015.1 
    2015-12-02 05:13:00,1.7,0.0,0.0,0.500024812603692,1014.4 
Run Code Online (Sandbox Code Playgroud)

我想获取整个数据集的每日降雪总和(新的一天重置为零)。我希望我的输出看起来像:

    2015-12-01,0.0
    2015-12-02,0.0
    2015-12-03,1.0
    2015-12-04,3.0
    2015-12-05,0.0
    2015-12-06,1.0
Run Code Online (Sandbox Code Playgroud)

如何使用熊猫来做到这一点?

python wunderground dataframe pandas

5
推荐指数
1
解决办法
2229
查看次数

将熊猫系列时间戳转换为唯一日期列表

我在 Pandas 数据框中有一列时间戳格式,并希望将唯一日期(无时间)提取到列表中。我试过以下方法并不奏效,

1. dates =  datetime.datetime(df['EventTime'].tolist()).date()
2. dates =  pd.to_datetime(df['EventTime']).date().tolist()
3. dates =  pd.to_datetime(df['EventTime']).tolist().date()
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

python datetime list pandas

3
推荐指数
1
解决办法
9534
查看次数

标签 统计

pandas ×2

python ×2

dataframe ×1

datetime ×1

list ×1

wunderground ×1