#COMMIT PANDAS TABLE 🔲
st.subheader("Commit Activity Timeline 🕒")
#created at parameter to dataframe with counts
cdate = pd.to_datetime(commits["createdAt"]).dt.date.value_counts().reset_index().sort_values("index")
#date range to fill null dates.
null_days = pd.date_range(start=cdate["index"].min(), end=cdate["index"].max())
#add null days to table
cdate = cdate.set_index("index").reindex(null_days, fill_value=0)
#reset index
cdate = cdate.reset_index()
#rename columns
cdate.columns = ["date", "count"]
#redate indexed dates
cdate["date"] = pd.to_datetime(cdate["date"]).dt.date
The Error I got is:
File “C:\Users\XXXX\Anaconda3\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “C:\Users\XXXX\SpeckleTutorials\01_specklePystreamActivityApp_tut01.py”, line 250, in
cdate = pd.to_datetime(commits[“createdAt”]).dt.date.value_counts().reset_index().sort_values(“index”)
File “C:\Users\XXXX\Anaconda3\lib\site-packages\pandas\core\frame.py”, line 6766, in sort_values
k = self._get_label_or_level_values(by, axis=axis)
File “C:\Users\XXXX\Anaconda3\lib\site-packages\pandas\core\generic.py”, line 1778, in _get_label_or_level_values
raise KeyError(key)
KeyError: ‘index’
Interesting, i tried to reproduce your error but couldn’t. The error indicated the issue i occurring in the “sort_values” method of the Pandas DataFrame. Can you check the column names in “cdate”?
Did this resolve the issue? If it did, please consider marking it as the solution. That way, anyone else who experiences the same issue in the future can benefit from it as well.
File “C:\Users\abhishek.shinde\Anaconda3\lib\site-packages\pandas\core\indexes\base.py”, line 3654, in get_loc
raise KeyError(key) from err
KeyError: ‘index’