attributeerror

Pandas pivot table aggregation with 'size' gives an error “'Series' object has no attribute 'columns'”

我只是一个虾纸丫 提交于 2020-05-17 07:04:50
问题 I have the following DataFrame: df = pd.DataFrame({'foo': [1, 3, 3, 4], 'bar': [2, 5, 8, 9], 'abc': [3, 7, 2, 4]}) When I tried using the command: df.pivot_table('bar', 'foo', aggfunc='size') I get the error: AttributeError: 'Series' object has no attribute 'columns' Strangely, the problem disappears when I aggregate several columns simultaneously: df.pivot_table(['bar', 'abc'], 'foo', aggfunc='size') But reappears again if I add the "dropna=False" parameter: df.pivot_table(['bar', 'abc'],

Pandas pivot table aggregation with 'size' gives an error “'Series' object has no attribute 'columns'”

自作多情 提交于 2020-05-17 07:04:27
问题 I have the following DataFrame: df = pd.DataFrame({'foo': [1, 3, 3, 4], 'bar': [2, 5, 8, 9], 'abc': [3, 7, 2, 4]}) When I tried using the command: df.pivot_table('bar', 'foo', aggfunc='size') I get the error: AttributeError: 'Series' object has no attribute 'columns' Strangely, the problem disappears when I aggregate several columns simultaneously: df.pivot_table(['bar', 'abc'], 'foo', aggfunc='size') But reappears again if I add the "dropna=False" parameter: df.pivot_table(['bar', 'abc'],

AttributeError: module Django.contrib.auth.views has no attribute

≯℡__Kan透↙ 提交于 2020-05-10 06:54:32
问题 In my Django app useraccounts, I created a Sign-Up form and a model for my Sign-up. However, when I went to run python manage.py makemigrations, I encounter the error: AttributeError: module Django.contrib.auth.views has no attribute 'registration'. Secondly, am I coding the SignUpForm in forms.py correctly? I did not want to use the User model in models because it would request username and I didn't want my website to ask for a username. Here is my code: models.py from django.db import

Django - Trying to create a GIF from uploaded video

余生长醉 提交于 2020-04-18 03:49:27
问题 I have a model class representing a video file. It has also a GIF field. I want to create also a GIF file of each video file. Before saving, I fill the gif field with the content of video field in the save() method like this: class Video(models.Model): created = models.DateTimeField(auto_now_add=True) text = models.CharField(max_length=100, blank=True) image = models.ImageField(upload_to='Images/',blank=True) video = models.FileField(upload_to='Videos/',blank=True) gif = models.FileField

Django - Trying to create a GIF from uploaded video

只愿长相守 提交于 2020-04-18 03:49:23
问题 I have a model class representing a video file. It has also a GIF field. I want to create also a GIF file of each video file. Before saving, I fill the gif field with the content of video field in the save() method like this: class Video(models.Model): created = models.DateTimeField(auto_now_add=True) text = models.CharField(max_length=100, blank=True) image = models.ImageField(upload_to='Images/',blank=True) video = models.FileField(upload_to='Videos/',blank=True) gif = models.FileField

Error while launching Jupyter Notebook - @attr.s(hash=True) AttributeError: module 'attr' has no attribute 's'

ぐ巨炮叔叔 提交于 2020-04-16 05:48:50
问题 I am not able to launch or open Jupyter Notebook. I have uninstalled and installed it multiple times, still get the same error which I have pasted below! It's giving some 'Attribute Error'. Traceback (most recent call last): File "C:\Users\Ramya\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in from notebook.notebookapp import main File "C:\Users\Ramya\anaconda3\lib\site-packages\notebook\notebookapp.py", line 80, in from .services.contents.manager import ContentsManager File "C:

Getting attribute error : module 'matplotlib.pyplot' has no attribute 'canvas'

淺唱寂寞╮ 提交于 2020-03-05 03:56:38
问题 plt.figure(figsize=(8, 8)) sns.heatmap(conf_matrix, annot=True, fmt="d"); plt.title("Confusion matrix") plt.ylabel('True class') plt.xlabel('Predicted class') html_fig = mpld3.fig_to_html(plt,template_type='general') plt.close(plt) Code in HTML file to fetch the image : <div id="fig_container"> {{ div_figure|safe }} </div> Using latest versions of Python and Django . On executing the attribute error is displayed module 'matplotlib.pyplot' has no attribute 'canvas' I am new to it and unable to

Getting attribute error : module 'matplotlib.pyplot' has no attribute 'canvas'

做~自己de王妃 提交于 2020-03-05 03:56:05
问题 plt.figure(figsize=(8, 8)) sns.heatmap(conf_matrix, annot=True, fmt="d"); plt.title("Confusion matrix") plt.ylabel('True class') plt.xlabel('Predicted class') html_fig = mpld3.fig_to_html(plt,template_type='general') plt.close(plt) Code in HTML file to fetch the image : <div id="fig_container"> {{ div_figure|safe }} </div> Using latest versions of Python and Django . On executing the attribute error is displayed module 'matplotlib.pyplot' has no attribute 'canvas' I am new to it and unable to

AttributeError: 'DataFrame' object has no attribute

大憨熊 提交于 2020-02-27 04:16:24
问题 I keep getting different attribute errors when trying to run this file in ipython...beginner with pandas so maybe I'm missing something Code: from pandas import Series, DataFrame import pandas as pd import json nan=float('NaN') data = [] with open('file.json') as f: for line in f: data.append(json.loads(line)) df = DataFrame(data, columns=['accepted', 'user', 'object', 'response']) clean = df.replace('NULL', nan) clean = clean.dropna() print clean.value_counts() AttributeError: 'DataFrame'

AttributeError: __enter__ while trying to take input from microphone

假装没事ソ 提交于 2020-02-25 06:40:43
问题 I had been trying to take input from microphone in my python program using speech_recognition I try to run this code: - import speech_recognition as sr import pyaudio r = sr.Recognizer() with sr.Microphone as source: audio = r.listen(source) text = r.recognize_google(audio) print(text) But it does not run. It says: - "C:\Users\Bravo Six\AppData\Local\Programs\Python\Python37-32\python.exe" "D:/BROTEEN/Works/Python/VALINI/speech testing.py" Traceback (most recent call last): File "D:/BROTEEN