Iteritems error loading dataframes

My app was working a week ago and today I found that it’s broked due to this error. I’ve been checking and I’m not able to load any dataframe due to the sale error and I’ve been trying some solutions but I didn’t found the good one. The error I’m writing below is the one that appears when I try to load a dataframe to use machine learning. Please, can someone help me?

Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/script_runner.py", line 379, in _run_script
    exec(code, module.__dict__)
  File "/app/eurovision_game_streamlit/main/streamlit_ESC.py", line 834, in <module>
    ctr.fit(X_train, y_train)
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 5300, in fit
    return self._fit(X, y, cat_features, None, None, None, sample_weight, None, None, None, None, baseline,
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 2021, in _fit
    train_params = self._prepare_train_params(
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 1907, in _prepare_train_params
    train_pool = _build_train_pool(X, y, cat_features, text_features, embedding_features, pairs,
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 1189, in _build_train_pool
    train_pool = Pool(X, y, cat_features=cat_features, text_features=text_features, embedding_features=embedding_features, pairs=pairs, weight=sample_weight, group_id=group_id,
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 628, in __init__
    self._init(data, label, cat_features, text_features, embedding_features, pairs, weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, timestamp, feature_names, thread_count)
  File "/home/appuser/venv/lib/python3.9/site-packages/catboost/core.py", line 1171, in _init
    self._init_pool(data, label, cat_features, text_features, embedding_features, pairs, weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, timestamp, feature_names, thread_count)
  File "_catboost.pyx", line 3751, in _catboost._PoolBase._init_pool
  File "_catboost.pyx", line 3799, in _catboost._PoolBase._init_pool
  File "_catboost.pyx", line 3634, in _catboost._PoolBase._init_features_order_layout_pool
  File "_catboost.pyx", line 2604, in _catboost._set_features_order_data_pd_data_frame
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 5989, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'iteritems'

That’s very strange – my best guess is that you have incompatible versions of libraries. Does this work for you locally? If so, you might need to use pip freeze to figure out exactly what versions of libraries you have, and pin to those specific versions in requirements.txt.

Hi, my requirements.txt is this:

matplotlib==3.4.3
pandas==2.0.1
plotly==5.4.0
wordcloud==1.8.1
opencv-python-headless==4.5.5.62
click==8.0.3
catboost==1.0.0
scikit-learn==1.1.0
altair==4.1.0
ipython
selenium==3.141.0
webdriver_manager==3.5.2
beautifulsoup4==4.10.0
streamlit==1.22.0
streamlit_extras==0.2.4
openpyxl
user-agents
streamlit_ace

And I added a paqueges.txt because it was needed to solve a problem weeks ago:
libgl1
cmake
libssl-dev

It looks like, among other things, that catboost 1.0.0 is not compatible pandas 2.0

Try installing at least catboost 1.2, since at a glance it looks like that’s when it started being compatible with pandas 2

1 Like

That works! Thank you!
Finally I’ve need to downgrade to pandas 1.5.3 also to keep my charts working with plotly.
Thanks again!

1 Like

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