• Register

Recent questions tagged python-python3-typeerror

0 votes
1 answer 5 views
Problem: I wrote a simple program which approximates the evaluation of a definite integral using numerical integration. However, I am stumped when it comes to why I am getting the error in the title. Keep in mind that I haven't touched python in one and a half years so it might be something incredibly obvious that I'm missing, however I'd still be grateful if you could help me
asked 3 days ago Mashhoodch 9.1k points
0 votes
1 answer 3 views
Problem: I am working on exercise 41 in learnpythonthehardway and keep getting the error: Traceback (most recent call last): File ".\url.py", line 72, in <module> question, answer = convert(snippet, phrase) File ".\url.py", line 50, in convert result = result ... TypeError: Can't convert 'bytes' object to str implicitly I am using python3 while the books uses python2, so I have made some changes.
asked 3 days ago Mashhoodch 9.1k points
0 votes
1 answer 5 views
Problem: I'm new to Python and have been trying to install some packages with pip. But pip install unroll gives me Command "python setup.py egg_info" failed with error code 1 in C:\Users\MARKAN~1\AppData\Local\Temp\pip-build-wa7uco0k\unroll\ How can I solve this?
asked Feb 18 Mashhoodch 9.1k points
0 votes
1 answer 34 views
Problem: I have a set of data with an Age column. I want to remove all the rows that are aged more than 90 and less than 1856. This is head of df: This is what I attempted:
asked Feb 15 Mashhoodch 9.1k points
0 votes
1 answer 22 views
Problem: I am unsure why I am getting this error count=int(input ("How many donuts do you have?")) if count <= 10: print ("number of donuts: " ) +str(count) else: print ("Number of donuts: many")
asked Feb 14 Mashhoodch 9.1k points
0 votes
1 answer 11 views
Problem: From Python: Attribute Error - 'NoneType' object has no attribute 'something': NoneType what means that instead of an instance of whatever Class or Object you think you're working with? you've actually got None. what That usually means that an assignment or function call up above failed or returned an unexpected result?
asked Jan 27 Mashhoodch 9.1k points
0 votes
1 answer 38 views
Problem: I am not an experienced programmer. I am trying to run following program: value = True number = [1,2,3,4] for i in number: if i%2 == 0 : value = True else: value = False for i in range(0, len(number)): print("The sequece of values is: ", ... false. The number that completely divides by 2 should print true and the others should print false. I have no idea what I am doing wrong. Any help?
asked Jan 16 Code Learner 5.8k points
0 votes
1 answer 42 views
Problem: This code generates error: IndexError: invalid index to scalar variable. at the line: results.append(RMSPE(np.expm1(y_train[testcv]), [y[1] for y in y_test])) How to fix it?
asked Jan 11 Mashhoodch 9.1k points
0 votes
1 answer 54 views
Problem: I am trying to install python package rpy2 with pip install on Ubuntu 16.04: pip install rpy2==2.2.7 but get error message (see full output below): Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-EuOI6K/unroll/
asked Jan 10 Mashhoodch 9.1k points
0 votes
1 answer 20 views
Problem: I'm seeing weird behavior on this code: images = dict(cover=[],second_row=[],additional_rows=[]) for pic in pictures: if len(images['cover']) == 0: images['cover'] = pic.path_thumb_l elif len(images['second_row']) < 3: images['second_row'].append(pic.path_thumb_m) ... == 0: TypeError: object of type 'NoneType' has no len() I can't figure out what's wrong in this. Maybe some scope issue?
asked Jan 10 Mashhoodch 9.1k points
0 votes
1 answer 60 views
Problem: have a dataframe (df) that looks like: date A 2001-01-02 1.0022 2001-01-03 1.1033 2001-01-04 1.1496 2001-01-05 1.1033 2015-03-30 126.3700 2015-03-31 124.4300 2015-04-01 124.2500 2015-04-02 124.8900 For the entire time-series I'm trying to divide today's value by yesterdays and log the result using the following: df["B"] = math.log(df["A"] / df["A"].shift(1))
asked Jan 10 Mashhoodch 9.1k points
0 votes
1 answer 10 views
Problem: I use Regex to retrieve certain content from a search box on a webpage with selenium.webDriver. searchbox = driver.find_element_by_class_name("searchbox") searchbox_result = re.match(r"^.*(?=(\())", searchbox).group() The code works as long as the search ... get error: AttributeError: 'NoneType' object has no attribute 'group' How can I make the script handle the "No results" situation?
asked Jan 9 Mashhoodch 9.1k points
0 votes
1 answer 46 views
Problem: I'm trying to fit an SGDRegressor to my data and then check the accuracy. The fitting works fine, but then the predictions are not in the same datatype(?) as the original target data, and I get the error ValueError: Can't handle mix of multiclass and continuous
asked Jan 9 Mashhoodch 9.1k points
0 votes
1 answer 11 views
Problem: On the last line, I got this error: builtins.TypeError: must be str, not bytes File "C:\PythonExamples\XmlReportGeneratorExample.py", line 29, in <module> doc.write(outFile) File "c:\Python32\Lib\site-packages\lxml\etree.pyd", line 1853, in lxml.etree._ElementTree.write (src/ ... etree.c:89527) I've installed Python 3.2, and I've installed lxml-2.3.win32-py3.2.exe. On Python 2.7 it works.
asked Jan 9 Mashhoodch 9.1k points
0 votes
1 answer 37 views
Problem: Hello! I am a beginner. I just moved from Java to Python programming just recently. I am learning the syntax of Python. I am trying to print the multiplication table using the while loop. I have written the following program in an attempt to do that: number ... to str implicitly I do not have any clue regarding this error. Can anybody here help me solving this error? I would be thankful.
asked Jan 8 Code Learner 5.8k points
0 votes
1 answer 51 views
Problem: I have this piece of code which creates a new note..WHen I try to print I get the following error even though it prints the output Error: C:\Python27\Basics\OOP\formytesting>python notebook.py Memo=This is my first memo, Tag=example Traceback (most recent call last): File "notebook.py", line 14, in <module> print(firstnote) TypeError: __str__ returned non-string (type NoneType)
asked Jan 8 Mashhoodch 9.1k points
0 votes
1 answer 16 views
Problem: Hi there! I am a new programmer, and I have started programming in Python just recently. I am facing a little difficulty in getting used to Python syntax. I am trying to run the following code: pi = "3.14"; floating = float(input("Enter a floating-point ... to subtract a value from the value of pi and print the answer. Could anybody here please point out the mistake I am making? Thanks!
asked Jan 8 Code Learner 5.8k points
0 votes
1 answer 28 views
Problem: File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/multiclass.py", line 172, in check_classification_targets raise ValueError("Unknown label type: %r" % y_type) ValueError: Unknown label type: 'continuous' The input data is the same as in the previous calls, ... way, why there is a huge diference in the first prediction of LinearRegression() and SVR() algorithms (15.72 vs 3.95)?
asked Jan 7 Mashhoodch 9.1k points
0 votes
1 answer 40 views
Problem: I have this python program that adds strings to integers: a = raw_input("Enter a: ") b = raw_input("Enter b: ") print "a + b as strings: " + a + b a = int(a) b = int(b) c = a + b str(c) print "a + b as integers: " + c I get this error: Python: TypeError: cannot concatenate 'str' and 'int' objects How can I add strings to integers?
asked Jan 7 Mashhoodch 9.1k points
0 votes
1 answer 13 views
Problem: A numpy matrix can be reshaped into a vector using reshape function with parameter -1. But I don't know what -1 means here. For example: a = numpy.matrix([[1, 2, 3, 4], [5, 6, 7, 8]]) b = numpy.reshape(a, -1) The result of b is: matrix ... anyone know what -1 means here? And it seems python assign -1 several meanings, such as: array[-1] means the last element. Can you give an explanation?
asked Jan 7 Mashhoodch 9.1k points