Hi all.
I am starting with this great tool, but I am having problems with memory when running the script. The script seem to compile without any problem, but inmediatelly occupy the whole ram of the computer and the swap (in ubuntu). It opens the app in the browser, displays the first few lines with basic inline information, but at the moment to display pyplots it crashes. Trying to see if it was a problem related with large data sets (the full data set contains ~1 millon lines), I started to only read smaller subsets of the data, smaller and smaller every time, but the problems remain exactly the same.
Bellow you will find the script that I am runnning.
import pandas as pd
import os
import numpy as np
import datetime
import glob
import streamlit as st
import matplotlib
import matplotlib.pyplot as plt
import plotly.graph_objs as go
import plotly.express as px
st.title('APP Oriente')
@st.cache
def load_data():
files_only = glob.glob('*.csv')
data = pd.DataFrame()
for i in files_only[0:100]:
df = pd.read_csv(i)
data = data.append(df)
index = np.arange(0,len(data))
data = data.set_index(index)
to_drop=['Bar Trend', 'Next Record',
'Inside Temperature', 'Inside Humidity',
'10 Min Avg Wind Speed', 'Extra Temperatures', 'Soil Temperatures', 'Leaf Temperatures',
'Extra Humidties', 'Storm Rain', 'Start Date of current Storm',
'Month Rain', 'Year Rain', 'Day ET', 'Month ET', 'Year ET',
'Soil Moistures', 'Leaf Wetnesses', 'Inside Alarms', 'Rain Alarms',
'Outside Alarms', 'Extra Temp/Hum Alarms', 'Soil & Leaf Alarms',
'Transmitter Battery Status', 'Console Battery Voltage',
'Forecast Icons', 'Forecast Rule number', 'Time of Sunrise',
'Time of Sunset', '<LF> = 0x0A', '<CR> = 0x0D', 'CRC']
data.drop(to_drop, axis=1)
data['Tiempo Sistema'] = pd.to_datetime(data['Tiempo Sistema']) - pd.to_timedelta(5,unit='h')
data['Rain Rate'] = data['Rain Rate']*0.2/10. #in units of cm/hour
data['Barometer'] = data['Barometer']/1000. + 760 # FALTA CORREGIR ESTE CLALCULO
data['Outside Temperature'] = ( data['Outside Temperature']/10. - 32.) * (5.0/9.0)
data.loc[(data['Outside Temperature'] > 50) | (data['Outside Temperature'] < -15)] = np.nan
return data
dt = load_data()
if st.checkbox('Mostrar datos'):
'## Data',dt[0:30]
'## Fecha/hora',dt['Tiempo Sistema'].iloc[-1]
'## Temperatura',round(dt['Outside Temperature'].iloc[-1],2)
'## Presión',dt['Barometer'].iloc[-1]
st.header("Plotly Temperatura")
time_temp_plt = go.Scatter(x=dt['Tiempo Sistema'], y=dt['Outside Temperature'], mode = 'markers')
dt_plt = [time_temp_plt]
layout = go.Layout(xaxis_title="Date [MM YY]", yaxis_title="Temperature [C]")
fig = go.Figure(data=dt_plt, layout=layout)
st.header("Plotly Presión")
time_temp_plt = go.Scatter(x=dt['Tiempo Sistema'], y=dt['Barometer'], mode = 'markers')
dt_plt = [time_temp_plt]
layout = go.Layout(xaxis_title="Date [MM YY]", yaxis_title="Presión [hpa]")
fig = go.Figure(data=dt_plt, layout=layout)
st.write(fig)
Any thoughts?
Thanks in advance.