attributeerror

no attribute named read_csv in pandas python

白昼怎懂夜的黑 提交于 2019-12-23 07:38:21
问题 I am new to machine learning and am creating a dataset using pandas in Python. I looked up a tutorial and was just trying out a basic code for creating a dataframe, but I keep getting the following trace-back: AttributeError: 'module' object has no attribute 'read_csv' I have saved the csv file in the csv(comma delimited) formatfrom Excel 13. Here's my code: import pandas import csv mydata = pandas.read_csv('foo.csv') target = mydata["Label"] data = mydata.ix[:,:-1] 回答1: There was a file

with os.scandir() raises AttributeError: __exit__

和自甴很熟 提交于 2019-12-23 07:11:13
问题 An AttributeError is raised when I use the example code from python's documentation (here). The example code is as follows: with os.scandir(path) as it: for entry in it: if not entry.name.startswith('.') and entry.is_file(): print(entry.name) The result is an AttributeError : D:\Programming>test.py Traceback (most recent call last): File "D:\Programming\test.py", line 3, in <module> with os.scandir() as it: AttributeError: __exit__ Although, assigning os.scandir() to a variable works fine.

Python AttributeError: module 'string' has no attribute 'maketrans'

末鹿安然 提交于 2019-12-23 02:28:14
问题 I am receiving the below error when trying to run a command in Python 3.5.2 shell: Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> folder = 'C:/users/kdotz/desktop' >>> f = open(folder + '/genesis.txt', 'r') >>> import operator, time, string >>> start=time.time() >>> genesis = {} >>> for line in f: line=line.split() for word in line: word = word.lower() new_word=word.translate

Skipping all unit tests but one in Python by using decorators and metaclasses

徘徊边缘 提交于 2019-12-22 18:05:47
问题 I am writing unit tests for an MCU that communicates commands through the USB port and checks their response. If one unit test fails it makes sense for me to do some debugging in the MCU. Therefore I would like to disable all unittests except for the one that I would like to debug on the MCU side because if I set a breakpoint somewhere it might get triggered by another unittest with different commands. I went to the python docs and found this code which is a decorator that will skip all

AttributeError: 'list' object has no attribute 'split'

£可爱£侵袭症+ 提交于 2019-12-22 06:31:18
问题 Using Python 2.7.3.1 I don't understand what the problem is with my coding! I get this error: AttributeError: 'list' object has no attribute 'split This is my code: myList = ['hello'] myList.split() 回答1: You can simply do list(myList[0]) as below: >>> myList = ['hello'] >>> myList=list(myList[0]) >>> myList ['h', 'e', 'l', 'l', 'o'] See documentation here 回答2: To achieve what you are looking for: myList = ['hello'] result = [c for c in myList[0]] # a list comprehension >>> print result ['h',

AttributeError: '_AppCtxGlobals' object has no attribute 'user' in Flask

自作多情 提交于 2019-12-20 18:29:51
问题 I'm trying to learn flask by following the Flask Mega Tutorial. In part 5, the login() view is edit like so: @app.route('/login', methods = ['GET', 'POST']) @oid.loginhandler def login(): if g.user is not None and g.user.is_authenticated(): return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): session['remember_me'] = form.remember_me.data return oid.try_login(form.openid.data, ask_for = ['nickname', 'email']) return render_template('login.html', title = 'Sign In'

AttributeError: 'Series' object has no attribute 'reshape'

拜拜、爱过 提交于 2019-12-20 17:41:24
问题 I'm using sci-kit learn linear regression algorithm. While scaling Y target feature with: Ys = scaler.fit_transform(Y) I got ValueError: Expected 2D array, got 1D array instead: After that I reshaped using: Ys = scaler.fit_transform(Y.reshape(-1,1)) But got error again: AttributeError: 'Series' object has no attribute 'reshape' So I checked pandas.Series documentation page and it says: reshape(*args, **kwargs) Deprecated since version 0.19.0. 回答1: Solution was linked on reshaped method on

Python SqlAlchemy - AttributeError: mapper

 ̄綄美尐妖づ 提交于 2019-12-20 05:40:53
问题 based on my model: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy.orm import relationship Base = declarative_base() class Session(Base): __tablename__ = 'sessions' id = Column(Integer, primary_key=True) token = Column(String(200)) user_id = Column(Integer, ForeignKey('app_users.id')) user = relationship('model.user.User', back_populates='sessions') I want to instantiate a new session through: session = Session

Python - AttributeError: '_io.TextIOWrapper' object has no attribute 'append'

六眼飞鱼酱① 提交于 2019-12-19 10:42:53
问题 I receive an error ClassFile.append(filelines) AttributeError: '_io.TextIOWrapper' object has no attribute 'append' while trying to write a file. It is about writing a file about pupil's scores, their name, lastname, classname (Just enter class as Class 1 )a scorecount of how many scores and their scores. Only their last 3 scores are to be kept in the file. I don't understand what this means. Here is the code score=3 counter=0 name=input('Name:') surname=input('Last Name:') Class=input('Class

Python3 AttributeError: 'list' object has no attribute 'clear'

和自甴很熟 提交于 2019-12-18 20:16:02
问题 I am working on a Linux machine with Python version 3.2.3. Whenever I try to do list.clear() I get an exception >>> l = [1, 2, 3, 4, 5, 6, 7] >>> l.clear() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'clear' At the same time on my Mac with Python 3.4.3 the same code runs smoothly. Can it be due to the difference between Python versions or is there something I'm missing? 回答1: list.clear was added in Python 3.3. Citing