I'm screwing around with python and its pandas library but I keep running into a problem. While copying through a tutorial, I try to get the version number for a couple libraries, but when I do so, I get the following: AttributeError: 'module' object has no attribute '_version_'
.
Everything else works just fine, but it really doesn't like '_version_'
for some reason. Anything I might be leaving out?
See below for the exact code.
import datetime
import pandas as pd
import pandas.io.data
from pandas import *
pd._version_
AttributeError: 'module' object has no attribute '_version_'
The Python "AttributeError: 'list' object has no attribute" occurs when we access an attribute that doesn't exist on a list. To solve the error, access the list element at a specific index or correct the assignment.
How to fix typeerror: 'module' object is not callable? To fix this error, we need to change the import statement in “mycode.py” file and specify a specific function in our import statement.
The Python "AttributeError: module has no attribute" occurs for multiple reasons: Having a circular dependency between files, e.g. file A imports file B and vice versa. Having a local module with the same name as an imported module. Having an incorrect import statement.
AttributeError can be defined as an error that is raised when an attribute reference or assignment fails. For example, if we take a variable x we are assigned a value of 10. In this process suppose we want to append another value to that variable. It's not possible.
Use double underscores..
In [10]: pandas.__version__
Out[10]: '0.13.1'
Which is just a shorthand for pandas.version.version
PEP8
suggests using __version__
as the global variable to store a version number. Most libraries follow this and then offer a more readable variable or possibly a function which outputs the version in a usable form (like Django for example).
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