Error when <import stringcase>

Hello!

I work over Car Sales Data currently:

Screen link

My Code:

pip install stringcase
import stringcase as stringcase
from stringcase import snakecase
etc.

What I expected to happen: what I could rename column names. Yesterday I got it :
<Index([‘date_crawled’, ‘name’, ‘seller’, ‘offer_type’, ‘price’, ‘abtest’,
‘vehicle_type’, ‘registration_year’, ‘gearbox’, ‘power__p_s’, ‘model’,
‘odometer’, ‘registration_month’, …> . But this morning I had to refresh the page and now I got the error for and .
It would be okay if new names of columns were saved in the data, but they returned to the previous format.

What actually happened:

  File "<ipython-input-21-5e486664b258>", line 2
    pip install stringcase
        ^
SyntaxError: invalid syntax

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-22-64bd8446b4af> in <module>
      1 #import stringcase and snakecase from the library
----> 2 import stringcase as stringcase
      3 from stringcase import snakecase

ModuleNotFoundError: No module named 'stringcase'

NameError: name 'snakecase' is not defined

I have the same errors on my local Jupyter Notebook from the beginning of the project. I really can’t find a way how to deal with this problem and would really appreciate any advice.

Hi
The problem, according to the error is that python is not understanding the command pip install stringcase so to solve that you can use ! pip install stringcase or % pip install stringcase

Good luck! let me know If you keep having any issue

% pip install worked properly.
Thank you very much)

It’s just curiously why yesterday python understood the command as it is without any additional symbols. Hard morning is the only option I can think up.

I think to avoid similar problems in the future saving the updated data in a new file is the best solution, isn’t it?

Well in the future you’ll work on your own environment, so it will be hard for it to forget that you installed something (except on google colab). But yeah, you can save the clean data in a new file, or you can create a pipeline that saves info in cache memory (I haven’t used pipelines for that so I’m no expert)

I’m glad that my answer helped you, good luck!