使用Dateutil _timelex

时间:2018-03-22 21:52:20

标签: python python-3.x pandas time-series

所以我一直在使用一个函数来合并时间序列数据,就在昨天我开始使用它时看到了这个折旧错误:

C:\Users\user\PycharmProjects\Hydrostats_tests\venv1\lib\site-
packages\dateutil\parser\__init__.py:46: 
DeprecationWarning: _timelex is a 
private class and may break without warning, 
it will be moved and or renamed in future versions. warnings.warn(msg, 
DeprecationWarning)

我正在运行的代码如下,我正在使用我制作的软件包。

import os
import hydrostats.data as hd

sim_dir = r'C:\Users\user\Documents\Data\interim_raw_data'
obs_dir = r'C:\Users\user\Documents\Data\recorded_raw_data'

sim_path = [os.path.join(sim_dir, d) for d in os.listdir(sim_dir)]
obs_path = [os.path.join(obs_dir, d) for d in os.listdir(obs_dir)]


visual_df = hd.merge_data(sim_path[0], obs_path[0])

这是合并数据功能:

def merge_data(predicted_file_path, recorded_file_path, interpolate=None, column_names=['Simulated', 'Observed'],
               predicted_tz=None, recorded_tz=None, interp_type='pchip'):

    if predicted_tz is None and recorded_tz:

        print('Either Both Timezones are required or neither')

    elif predicted_tz and recorded_tz is None:

        print('Either Both Timezones are required or neither')

    elif predicted_tz is None and recorded_tz is None and interpolate is None:

        # Importing data into a data-frame
        df_predicted = pd.read_csv(predicted_file_path, delimiter=",", header=None, names=[column_names[0]],
                                   index_col=0, infer_datetime_format=True, skiprows=1)
        df_recorded = pd.read_csv(recorded_file_path, delimiter=",", header=None, names=[column_names[1]],
                                  index_col=0, infer_datetime_format=True, skiprows=1)
        # Converting the index to datetime type
        df_recorded.index = pd.to_datetime(df_recorded.index, infer_datetime_format=True)
        df_predicted.index = pd.to_datetime(df_predicted.index, infer_datetime_format=True)

        return pd.DataFrame.join(df_predicted, df_recorded).dropna()

错误发生在这两行

df_recorded.index = pd.to_datetime(df_recorded.index,infer_datetime_format =真) df_predicted.index = pd.to_datetime(df_predicted.index,infer_datetime_format =真)

我正在阅读的csv数据如下所示:

Datetime,recorded streamflow (m^3/s)
1962-02-23,160.0
1962-02-24,163.0
1962-02-25,178.0
1962-02-26,169.0
1962-02-27,169.0
1962-02-28,169.0
1962-03-01,169.0
1962-03-02,163.0
1962-03-03,160.0
1962-03-04,158.0
1962-03-05,195.0

我在线查找了这个错误,并且我尝试使用调试器,但是我无法看到此错误的来源。我想有一个更新,但我不确定是什么更新导致此错误。

任何帮助将不胜感激,谢谢!

0 个答案:

没有答案