Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas read_csv error due to pandas.io.common not importing is_url in 1.0.x

Tags:

python

pandas

I'm trying to read in a regular csv file into pandas through pd.read_csv(). I have done this on my local desktop many times before but I am using a virtual machine now and am getting this error :

ImportError: cannot import name 'is_url' from 'pandas.io.common' (/opt/conda/lib/python3.7/site-packages/pandas/io/common.py)

Can anyone help me understand what's happening and how to resolve it? I have tried updating as well as uninstalling and reinstalling pandas already.

like image 751
Altamash Rafiq Avatar asked Feb 13 '20 01:02

Altamash Rafiq


People also ask

How useful is pandas when importing the CSV file?

You now have a good sense of how useful pandas is when importing the CSV file, and conveniently, pandas offers other similar and equally handy functions to import Excel, SAS, and Stata files to name a few. Yet, due to the active community in open source software, there is constant activity in file formats and ways to import data.

Why is my pandas read_CSV() not working?

The pandas read_csv () allows you to read a CSV file from a specific path. The root cause for this attributerror is that python is unable to interpret the read_csv () method. Suppose I will read the following lines of code then I will get the attributeerror: module ‘pandas’ has no attribute ‘read_csv’.

Why can't I read a CSV file from a specific path?

The pandas read_csv () allows you to read a CSV file from a specific path. The root cause for this attributerror is that python is unable to interpret the read_csv () method.

Why are my pandas data types encoding missing values as 'no info'?

In pandas, columns with a string value are stored as type object by default. Because missing values in this dataset appear to be encoded as either 'no info' or '.', both string values, checking the data type for a column with missing values such as the fat column, you can see that its data type isn't ideal:


2 Answers

conda update --force-reinstall pandas

this worked for me.

like image 76
melkorCba Avatar answered Sep 19 '22 07:09

melkorCba


I had the same problem. it showed up after I updated all the libraries with conda (trying to fix something else). After print the version of pandas inside the notebook, it showed as a really old one (0.3.somehing, can not remember the exact number). but strangely , my other notebook files were showing pandas version as 1.0.2, and i was able to load csv in those files without ImportError . So i went back to conda and upgraded pandas again just by itself, restarted conda, ran the code again , fixed it . Hope it helps.

like image 28
daisy Avatar answered Sep 22 '22 07:09

daisy