I am unable to read data in Pandas: Input:
import pandas as pd
data = 'a,b,c\n1,2,3\n4,5,6'
pd.read_csv(StringIO(data),skipinitialspace=True)
Output:
NameError:name 'StringIO' is not defined
Please let me know why the error occurred and also let me know what to import.
Try to add the below packages These packages should add this line at the beginning of your script.
import io
from io import StringIO
import string
import pandas as pd
from pandas.compat import StringIO
from collections import Counter
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
After adding the above packages I am not getting the below error
ModuleNotFoundError: No module named 'StringIO'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With