0

I have looked at several other similar questions but their fixes are not working for me. I am running my script in a conda venv but I already installed pandas within said environment. I will show my code and the error I get when running from the terminal. Obviously, the directory of the virtual environment is not the same as the directory of my css file, which is why I give the file path to the file. I must add that within VS Code, I am able to get the data set and add items to the list I created (although the while loop is not currently working). Can anyone help?

import pandas as pd
import random


data_set = pd.read_csv("/Users/rickvillanueva/Documents/Myron/dated_random.csv")

random_data = data_set.MYRON_ACCT

random_names = []

random_gatherer = True
#Gathering random account numbers
while random_gatherer:
    one = random.choice(random_data)
    random_names.append(one)
    if len(random_names) < 50:
        random_gatherer = True
        continue
    else:
        break

len(random_names)
print(random_names)

Error I get in terminal:

Traceback (most recent call last):
  File "random.py", line 1, in <module>
    import pandas as pd
  File "/Users/rickvillanueva/opt/anaconda3/lib/python3.7/site-packages/pandas/__init__.py", line 11, in <module>
    __import__(dependency)
  File "/Users/rickvillanueva/opt/anaconda3/lib/python3.7/site-packages/numpy/__init__.py", line 152, in <module>
    from . import random
  File "/Users/rickvillanueva/opt/anaconda3/lib/python3.7/site-packages/numpy/random/__init__.py", line 181, in <module>
    from . import _pickle
  File "/Users/rickvillanueva/opt/anaconda3/lib/python3.7/site-packages/numpy/random/_pickle.py", line 1, in <module>
    from .mtrand import RandomState
  File "_bit_generator.pxd", line 14, in init numpy.random.mtrand
  File "_bit_generator.pyx", line 40, in init numpy.random._bit_generator
  File "/Users/rickvillanueva/opt/anaconda3/lib/python3.7/secrets.py", line 20, in <module>
    from random import SystemRandom
  File "/Users/rickvillanueva/Documents/Myron/random.py", line 5, in <module>
    data_set = pd.read_csv("/Users/rickvillanueva/Documents/Myron/dated_random.csv")
AttributeError: module 'pandas' has no attribute 'read_csv'
8
  • Which version of panda are you running? Execute: print(pd.__version__) Commented May 14, 2020 at 17:15
  • Do have a package in your project named pandas? Commented May 14, 2020 at 17:16
  • Don't name your file random.py. That screws with a builtin module. Rename your file. You can see that it's screwing with numpy in the traceback Commented May 14, 2020 at 17:17
  • @roganjosh Do I have to keep the .py termination? Commented May 14, 2020 at 17:19
  • @RickVillanueva yes keep the .py just change the name Commented May 14, 2020 at 17:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.