0

I am running Python 2.7.10 on a Macbook.

I have installed: Homebrew Python 2.x, 3.x NI-VISA pip pyvisa, pyserial, numpy PyVISA Anaconda Pandas I am attempting to run this script. A portion of it can be read here:

import visa
import time
import panda
import sys
import os
import numpy

os.system('cls' if os.name == 'nt' else 'clear')    #clear screen
rm = visa.ResourceManager()
rm.list_resources()

print(rm.list_resources())

results = panda.DataFrame(columns=['CURR', 'VOLT', 'TIME'])

This is what is returned on the command line, below.

Note the line that says

AttributeError: 'module' object has no attribute 'DataFrame'

(u'USB0::0x05E6::0x2280::4068201::INSTR', u'ASRL1::INSTR', u'ASRL2::INSTR', u'ASRL4::INSTR')
Traceback (most recent call last):
  File "k2280.py", line 14, in <module>
    results = panda.DataFrame(columns=['CURR', 'VOLT', 'TIME'])
AttributeError: 'module' object has no attribute 'DataFrame'

Any help or insight on this issue would be appreciated.

2
  • I assume you want to import pandas and not panda? And your line results = should be results = pandas.DataFrame(columns=['CURR', 'VOLT', 'TIME']) Commented Nov 26, 2018 at 21:40
  • Okay, I am trying that now with Python 3 instead of Python 2 Commented Nov 26, 2018 at 21:53

3 Answers 3

2

It's pandas, not panda, so use import pandas instead. It's also common practice to import pandas as pd for convenience:

import pandas as pd
df = pd.DataFrame()
Sign up to request clarification or add additional context in comments.

Comments

1

The module is called pandas not panda

python3 -m pip install pandas

import pandas as pd

pd.DataFrame()

3 Comments

Yes, I tried using pandas before but it did not work. Let me try installing pandas again on Python3
If you want to stick to python2 then just use "python -m pip install pandas"
I think that just resolved it! Great thank you. It's strange I am sure I tried that command before but it didn't work...
1

Please read if you're new to python. As I am also new to python since 2 days and going through the tutorial. What I know is pandas are the packages we install in the python library to the machine we are using. As I am new and I was practicing to import and use pandas.DataFrame I kept my filename as pandas.py

And here is the error I was doing. I can't use pandas.py because the machine is assuming its module inside this pandas.py

I changed the filename and it start working fine.

Few things to know if you're getting errors.

  1. You are using pandas.py as filename, you need to change the file name
  2. You are not importing pandas in the file and started working on its module
  3. You are not using DataFrame in camel case

I think these 3 things should be kept in mind to use DataFrame to avoid this error.

Comments

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.