import pandas as pd
import numpy as np
import datetime
import itertools
import os
import csv
from fredapi import Fred
所以我连接Fed API并执行以下操作(data_i只是存储来自FED的数据并创建数据帧。
df1 = pd.DataFrame(data={"CUSR0000SEFV": data3, "CUUR0000SEFV": data4, "CPIAUCSL": data5,"CPIAUCNS":data6,"UNRATE": data7,"UNRATENSA":data8})
macro3 = df1
macro3.reset_index(inplace=True)
macro3.rename(columns={'index': 'date'}, inplace=True)
我得到以下
date col1 col2 ...
2011-01-01 220.223 221.187
2011-02-01 221.309 221.898
我需要帮助才能将其转换为此
date col1 col2 ...
2011-01-02 220.223 221.187
2011-01-09 220.223 221.187
2011-01-16 220.223 221.187
我尝试过这样做,但我只是不知道如何聚合和打印重复项
macro3.date = (macro3.date + datetime.timedelta(days=7))
答案 0 :(得分:1)
您可以使用class Dog implements RedMapleWoodCompartment.Prisoner, RedOakWoodCompartment.Prisoner, MetalCompartment.Prisoner, RedPlasticCompartment.Prisoner {
}
class Elephant implements BlackOakWoodCompartment.Prisoner, MetalCompartment.Prisoner, BluePlasticCompartment.Prisoner, RedPlasticCompartment.Prisoner {
}
class Cat implements MetalCompartment.Prisoner, BluePlasticCompartment.Prisoner {
}
和填充方法。例如,这个将频率更改为每周一次:
resample()