Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Seems like an incredibly basic error, I've tried uninstalling and reinstalling the latest version of Numpy (1.9) and that didn't seem to solve my issue. I am getting the following error when trying to use the arrange function:
Traceback (most recent call last):
File "names.py", line 37, in <module>
top1000.index = np.arrange(len(top1000))
AttributeError: 'module' object has no attribute 'arrange'
Printing the version confirms that it is indeed 1.9. I've not been able to come across anyone else reporting this specific issue. I've also tried this on two separate Macs and still get the same exact error.
import numpy as np
import pandas as pd
print np.__version__
grouped = names.groupby(['year', 'sex'])
top1000 = grouped.apply(get_top1000)
top1000.index = np.arrange(len(top1000))
You should try numpy.arange() instead, if that is what you meant?
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 12 months ago.
Improve this question
Just starting out learning Python and programming in general. Following along with a video on LIL and everything has worked fine up until now. I'm trying to access the first 3 rows of a specified series with the following code. I keep getting a syntax error where it highlights my colon. What am I doing wrong? It looks exactly like the text in the video.
import pandas as pd
import xlsxwriter
from openpyxl.workbook import Workbook
df = pd.read_excel("C:/Users/Aaron/Desktop/filename.xlsx")
print(df['Visit '],[1:3])
print(df['Visit '],[1:3])
The placement of the comma means you are passing two separate items to print():
df['Visit ']
[1:3]
The problem is the second item. [1:3] is not valid by itself.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to make a script that can delete a file with Python. When I moved the file to my startup directory with my script, a lot of the code was changed, not by me. I've just assumed this was normal and continued trying to make it delete a file on startup. I later realized it wasn't working because one of the call methods kept getting an invalid syntax. Here's my code.
Python Version: 3.8.7
Error message is :
invalid syntax (<unknown>, line 7)
LOAD_CONST(0), LOAD_CONST(None), IMPORT_NAME(os), STORE_NAME(os)
LOAD_CONST(0), LOAD_CONST(None), IMPORT_NAME(shutil), STORE_NAME(shutil)
source = 'C:\\Users\\me\\OneDrive\\Desktop\\startup.py'
destination = 'C:\\Users\\me\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup'
LOAD_NAME(shutil), LOAD_METHOD(move), LOAD_NAME(source), LOAD_NAME(destination), CALL_METHOD[2], STORE_NAME(new_path)
print(new_path)
LOAD_NAME(os), LOAD_METHOD(remove), LOAD_CONST('C:/Users/me/OneDrive/Desktop/delete.txt'), CALL_METHOD[1], POP_TOP
print('File Removed!'), return None
From the code, it's difficult to understand what you are trying to do. If you want to delete a file, you can use the os module in python. For example:
import os
os.remove("/some/file/path/to/remove.txt")
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am using google colab sheet.
Before a minute this line was working but I don't what happened now.
----> 3 rang = [num for num in range(100)]
TypeError: 'list' object is not callable
This error is coming every time, I tried refreshing the page.
Looks like you accidentally defined range somewhere within your code. This overwrote the built-in definition. The line may look something like range = [1, 2, 3].
You should find and get rid of that line. Then, refresh your kernel to bring back the regular definition of range.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I am working on Object detection with tensorflow api. I take codes on githup and try to debug and I face to face that error.
File "<ipython-input-10-7adfcc2a8173>", line 3, in <module>
with detection_graph.as_defult():
AttributeError: 'Graph' object has no attribute 'as_defult'
No problem with my camera. I aldready installed which necessary every module
PLSS help me
thank you
Without your code I cannot be entirely certain it is the only issue, but I think you are getting the error because of a misspelling. It should be as_default instead of as_defult. Use detection_graph.as_default() instead.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Here's the script
#!/usr/bin/python
class LEG(Structure):
_fields_ = [("distance_sm", c_float), ("distance_nm", c_float)]
Here's what I get when I run it.
Traceback (most recent call last):
File "./test.py", line 3, in <module>
class LEG(Structure):
NameError: name 'Structure' is not defined
Yes, brand new to python, thanks for your help
It looks like you're trying to use the Structure type from the ctypes module. You need to import that, as well as c_float and anything else you use from that module:
from ctypes import Structure, c_float