Hier ist ein Beispiel für mein Prophet-Plot-Ausgang: Prophetausgabe < /p>
rot ist der tatsächliche Wert und Blau ist das, was Prophet für diese Zeitrahmen vorhergesagt hat. Ich kann ein Beispiel für CSV bereitstellen und würde jede Hilfe schätzen.
Code: Select all
import os
import pandas as pd
from prophet import Prophet
import matplotlib.pyplot as plt
import numpy as np
input_folder = 'Example-Folder'
forecast_folder_path = 'Example-Folder_forecast'
os.makedirs(forecast_folder_path, exist_ok=True)
needed_columns = {
'B': "Example-Location"
'C': "Example-Location"
'D': "Example-Location"
'E': "Example-Location"
'F': "Example-Location"
}
column_indices = {'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5}
combined_data = pd.DataFrame()
all_forecasts = {}
for file_name in os.listdir(input_folder):
if file_name.endswith('.csv') and '0125' not in file_name:
file_path = os.path.join(input_folder, file_name)
df = pd.read_csv(file_path, delimiter=';', on_bad_lines='skip', header=None)
if df.shape[1] >= 6:
cols = [0] + list(column_indices.values())
df = df.iloc[:, cols]
df.columns = ['ds'] + [needed_columns[key] for key in column_indices]
df['ds'] = pd.to_datetime(df['ds'], errors='coerce')
for col in df.columns[1:]:
df[col] = pd.to_numeric(df[col], errors='coerce')
df[col] = df[col].apply(lambda x: x if x > 0 else np.nan)
df = df.ffill().bfill()
combined_data = pd.concat([combined_data, df])
combined_data = combined_data[combined_data['ds']