I am trying to create a countplot with sns. I adapted the following code:
sns.countplot(x="deck", data=titanic, palette="Greens_d")
I use a data frame called dfvp where XP is a categorical variable which can take two string values (either defense or prosecution).
here is my adapted code:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Here is the error message that I get:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Traceback (most recent call last):
File "<ipython-input-220-20d65ae5d282>", line 1, in <module>
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
AttributeError: 'module' object has no attribute 'countplot'
FYI: I use ANACONDA and Python 3.4. on a PC with Windows 8.
Could you tell me how to fix this/what I am doing wrong?
EDIT:
Here is a MCVE
import seaborn as sns
dfvp = read_csv('C:\\Users\\VP_Prod_study_2_data changed_3.csv')
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Related
I'm still learning to use FatSym to analyze medical images; But I keep getting this error 'FlatSym' object has no attribute 'array' This is my code
pip install numpy
pip install pylinac
from pylinac import FlatSym
my_file = r"C:\Users\xxxx.dcm"
my_img = FlatSym(path=my_file)
my_img.analyze(flatness_method='varian', symmetry_method='varian', vert_position=0.5, horiz_position=0.5)
AttributeError Traceback (most recent call last)
<ipython-input-25-0bda45c5e24c> in <module>
----> 1 my_img.analyze(flatness_method='varian', symmetry_method='varian', vert_position=0.5, horiz_position=0.5)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in analyze(self, flatness_method, symmetry_method, vert_position, horiz_position, vert_width, horiz_width)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in _calc_symmetry(self, method, vert_position, horiz_position, vert_width, horiz_width)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in _get_vert_profile(self, vert_position, vert_width)
AttributeError: 'FlatSym' object has no attribute 'array'
What i'm missing here please? Thanks!
FlatSym you have imported is an object try this
from pylinac import FlatSym
my_file = r"C:\Users\xxxx.dcm"
my_img = FlatSym(my_file)
I am new to numpy and I am NOT understanding the documentation as regards diff. the code below throws the error. I am baffled any help would be appreciated.
Traceback (most recent call last):
File "/home/dave/Desktop/mcmtest/testhv calc.py", line 11, in <module>
r = np.log(close_prices).diff()
AttributeError: 'numpy.ndarray' object has no attribute 'diff'
here is the test code.
import numpy as np
from numpy import sqrt,mean,log,diff
import pandas as pd
close_prices = [178.97,175.5,171.07,171.85,172.43,172.99,167.37,164.34,162.71,\
156.41,155.15,159.54,163.03,156.49,160.5,167.78,167.43,166.97,167.96,171.51,171.11]
print (close_prices)
r = np.log(close_prices).diff()
print(r)
Given that numpy.ndarray is the Python type of "numpy arrays", the error is just saying that arrays don't have a diff method. diff is a function defined in the numpy module.
Instead of np.log(close_prices).diff(), do
np.diff(np.log(close_prices))
I have some problem which i cannot find answer to. After installing scikit-video and FFmpeg i got this error:
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
can you help me to find solution to this.
from skvideo.io import FFmpegWriter
def main():
...
video_writer = FFmpegWriter('video.mp4')
...
if __name__ == '__main__':
main()
Already tried to install pyaudio, reinstall FFmpeg and skvideo and install different versions of packages. Does not help at all.
Edit: an example of the full traceback resulting from /skvideo/io/abstract.py is below.
Traceback (most recent call last):
File "run_modules.py", line 93, in <module>
Pipeline.create_videos(video_attr, args.output_path, args.padded)
File "/home/leuko/.local/lib/python3.6/site-packages/skvideo/io/abstract.py", line 474, in close
if self._proc is None: # pragma: no cover
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
I just ran into this issue, and found that FFmpegWriter was actually masking another error. My code was roughly like this:
with FFmpegWriter('/tmp/tmp.webm') as writer:
for frame in frames:
<code to generate out>
writer.writeFrame(out)
The code block before writer.writeFrame was raising an error, but I didn't see that because I didn't look at the full stack trace. I couldn't figure out why FFmpegWriter was throwing this error, but it made sense once I realized I wasn't actually writing any frames but was then trying to close the writer.
I was following an animation example with Python in Blender 2.69, by typing a line by line.
obj = bpy.context.object
obj.location[2] = 0.0
obj.keyframe_insert(data_path="location", frame=10.0, index=2)
obj.location[2] = 1.0
obj.keyframe_insert(data_path="location", frame=20.0, index=2)
But I have encountered an error on the 3rd line, which is saying
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'location'
I am confused because I just followed a simple example.
Why is it saying the object has no attribute 'location'?
I'll be appreciated for your help, thanks.
You'll find that the error would be reported after the second line because the variable obj has not been set. Most likely this would be from a small typo.
You can verify this by looking at the type of the variable in the python console. When getting the error you will see -
>>> type(obj)
<class 'NoneType'>
While if it had been set correctly you will get -
>>> type(obj)
<class 'bpy_types.Object'>
I'm fresh on python,using python2.7,and got some questions on the code blew:
import numpy as np
from scipy import interpolate
import pylab as py
x=np.r_[0:10:11j]
y=np.sin(x)
xnew=np.r_[0:10:100j]
#f=interpolate.interpld(x,y)
py.figure(1)
py.clf()
py.plot(x,y,'ro')
for kind in ['nearest','zero','slinear','quadtatic','cublic']:
f=interpolate.interpld(x,y,kind=kind)
ynew=f(xnew)
py.plot(xnew,ynew,label=kind)
py.legend(loc='lower right')
but it resulted in:
Traceback (most recent call last):
File "C:\Users\LCL\.xy\startups\python_web\my_first_try_on_python_web\python_Interpolation\example1.py", line 22, in <module>
f=interpolate.interpld(x,y,kind=kind)
AttributeError: 'module' object has no attribute 'interpld'
You used interpld, i.e. INTERPLD.
You want interp1d, i.e. with the numeral 1, for one-dimensional.
It looks like you are using interpolate.interpld but the function name is interpolate.interp1d (with a number one instead of a letter L).
It should be "interp1d",the number 1,not L