从以下代码开始:
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')
数据帧是这样的:
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
索引已在datetime中。目标是将上面的索引替换为下面的代码创建的新索引,并将所有值保留在vento列中:
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')
得到这样的索引:
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
期望输出:
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
如果有人能帮忙我会很感激的。你知道吗
数据源:
解决方案:
相关问题 更多 >
编程相关推荐