简体   繁体   中英

python create multiple year daterange with specific end date for every year

Hello need some help with this problem

a = pd.date_range(start="2001-01-01", freq="T", periods=520000)

This creates the date-range i need for 1 year. I want to do the same for the next 80 years. The end result should be a date range for 80year but every year ends after 520000min. Then i add the date range to my dataset.

# this is the data
ALL_Data = pd.DataFrame({"Lebensverbrauch_Min": LebensverbrauchMIN,
                             "HPT": Heisspunkttemperatur_Sim1,
                             "Innentemperatur": StartS,
                             "Verlustleistung": V_Leistung,
                            "SolarEintrag": SolarEintrag,
                            "Lastfaktor": K_Load_Faktor
                             })

# How many minutes are left in the year
    DatenJahr = len(pd.date_range(start=str(xx) + "-01-01", freq="T", periods=520000))
    VollesJahr = len(pd.date_range(start=str(xx) + "-01-01", freq="T", end=str(xx + 1) + "-01-01"))
    GG = (VollesJahr - DatenJahr)
    d = pd.DataFrame(np.zeros((GG, 6)), columns=['Lebensverbrauch_Min', 'HPT', 'Innentemperatur','Verlustleistung',
                                                'SolarEintrag', 'Lastfaktor',])
#combine Data with 0
    ALL_Data = pd.concat([ALL_Data, d])

seems to work but the complete code needs 4h to run so we will see

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM