Depplyment works on localhost but not on the cloud

My app works on my local host but not on the cloud. This is the error message I get:
TypeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

This is the link to my app and my GitHub repository

Appreciate any help I can get

Can you look in the Manage App tab and share the full error message?

The error message is too big to put here but here’s the last part of it:

Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 1696, in _ensure_numeric
x = complex(x)
ValueError: complex() arg is a malformed string

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/”, line 563, in _run_script
exec(code, module.dict)
File “/app/floridagolf/”, line 169, in
ecc_duration_by_name = df_selection.groupby(by=[“Date”]).mean()[["Eccentric Duration [ms] “]]
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1855, in mean
result = self._cython_agg_general(
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1507, in _cython_agg_general
new_mgr = data.grouped_reduce(array_func)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/internals/”, line 1503, in grouped_reduce
applied = sb.apply(func)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/internals/”, line 329, in apply
result = func(self.values, **kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1503, in array_func
result = self._agg_py_fallback(values, ndim=data.ndim, alt=alt)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1457, in _agg_py_fallback
res_values = self.grouper.agg_series(ser, alt, preserve_dtype=True)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 994, in agg_series
result = self._aggregate_series_pure_python(obj, func)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1015, in _aggregate_series_pure_python
res = func(group)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/groupby/”, line 1857, in
alt=lambda x: Series(x).mean(numeric_only=numeric_only),
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 11556, in mean
return NDFrame.mean(self, axis, skipna, numeric_only, **kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 11201, in mean
return self._stat_function(
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 11158, in _stat_function
return self._reduce(
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 4670, in _reduce
return op(delegate, skipna=skipna, **kwds)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 96, in _f
return f(*args, **kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 158, in f
result = alt(values, axis=axis, skipna=skipna, **kwds)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 421, in new_func
result = func(values, axis=axis, skipna=skipna, mask=mask, **kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 727, in nanmean
the_sum = _ensure_numeric(values.sum(axis, dtype=dtype_sum))
File “/home/appuser/venv/lib/python3.9/site-packages/pandas/core/”, line 1699, in _ensure_numeric
raise TypeError(f"Could not convert {x} to numeric”) from err
TypeError: Could not convert Luke PoulterTyler WilkesMatthew KressRyan HartMiguel Leal to numeric

It looks like there must be a version difference locally and on cloud that affects how groupby...mean() is handling non-numeric columns.

If you pass numeric_only=True like this:

    ecc_duration_by_name = df_selection.groupby(by=["Date"]).mean(numeric_only=True)[["Eccentric Duration [ms] "]]

It should fix that error.

Two other comments:

  1. You’re doing that df_selection.groupby(by=["Date"]).mean quite a few times – you could do that once, called it “df_by_date” and use that for all the rest of the times
  2. The password is hard-coded into the page, so that anyone with access to the code can see it. A better alternative is to use for the password so that it’s not actually in your code.

Also, looks like a cool app!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.