Starting with this code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
vento=pd.read_csv('dados_tpm.txt')
vento.rename(columns={'Dia_Mes_Ano_Hora_Minuto': 'Data'})
vento.set_index('Data')
The dataframe is something like this:
Data Vel Dir
2016-07-12 16:26:00 2.4 21.0
2016-07-12 16:27:00 1.7 17.8
2016-07-12 16:29:00 14.3 14.9
The index is already in datetime. The objective is to substitute the index above to a new index created by this code below and keep all values in vento columns:
vento3 = pd.DataFrame({'Data':pd.date_range(start='2016-07-12 16:17:00',end='2017-04-30 22:34:00',freq='1Min')})
vento3.set_index('Data')
Getting this index like:
Data
2016-07-12 16:26:00
2016-07-12 16:27:00
2016-07-12 16:28:00
2016-07-12 16:29:00
Desired output:
Data Vel Dir
2016-07-12 16:26:00 2.4 21.0
2016-07-12 16:27:00 1.7 17.8
2016-07-12 16:28:00 NaN NaN
2016-07-12 16:29:00 14.3 14.9
Would be thankful if someone could help.
vento.reindex(pd.date_range(start='2016-07-12 16:17:00',end='2017-04-30 22:34:00',freq='1Min'))