Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,12 @@ import matplotlib.pyplot as plt
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
def plot_time_series(data):
|
| 6 |
-
#
|
|
|
|
|
|
|
| 7 |
df = pd.DataFrame(data, columns=["date", "value"])
|
| 8 |
df["date"] = pd.to_datetime(df["date"])
|
|
|
|
| 9 |
|
| 10 |
# Criar o gráfico de linhas da série temporal
|
| 11 |
plt.figure(figsize=(10, 6))
|
|
@@ -17,7 +20,7 @@ def plot_time_series(data):
|
|
| 17 |
plt.tight_layout()
|
| 18 |
plt.show()
|
| 19 |
|
| 20 |
-
#
|
| 21 |
iface = gr.Interface(
|
| 22 |
fn=plot_time_series,
|
| 23 |
inputs=gr.inputs.Textbox(label="Insira a série temporal em formato de tabela com duas colunas: 'date' e 'value'"),
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
def plot_time_series(data):
|
| 6 |
+
# Processar os dados da série temporal
|
| 7 |
+
lines = data.strip().split("\n")
|
| 8 |
+
data = [line.strip().split(",") for line in lines]
|
| 9 |
df = pd.DataFrame(data, columns=["date", "value"])
|
| 10 |
df["date"] = pd.to_datetime(df["date"])
|
| 11 |
+
df["value"] = df["value"].astype(float)
|
| 12 |
|
| 13 |
# Criar o gráfico de linhas da série temporal
|
| 14 |
plt.figure(figsize=(10, 6))
|
|
|
|
| 20 |
plt.tight_layout()
|
| 21 |
plt.show()
|
| 22 |
|
| 23 |
+
# Criar a interface Gradio
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=plot_time_series,
|
| 26 |
inputs=gr.inputs.Textbox(label="Insira a série temporal em formato de tabela com duas colunas: 'date' e 'value'"),
|