nonetype Questions
8
Solved
I've been writing a lot of constructs like this the past couple of days:
list = get_list()
if list:
for i in list:
pass # do something with the list
else:
pass # do something if the list was em...
12
Solved
I have the following code snippet:
user = User(username='[email protected]',email='[email protected]')
user.set_password('pass')
user.save()
u = authenticate(username='[email protec...
Lecia asked 6/9, 2013 at 17:11
3
I have a function with four parameters a, b, c and d as shown below.
def myfunc(a=None,b=None,c=None,d=None):
if <check which are not None>:
myfunc2(<pass those which are not None>)...
Hire asked 3/11, 2021 at 4:35
8
Solved
I'd like to distinguish between None and empty strings ('') when going back and forth between Python data structure and csv representation using Python's csv module.
My issue is that when I run:
im...
11
Solved
I am getting an error message that says
AttributeError: 'NoneType' object has no attribute 'something'
How can I understand this message?
What general scenarios might cause such an AttributeError,...
Excessive asked 20/1, 2012 at 23:38
9
Solved
I have a df with two columns and I want to combine both columns ignoring the NaN values. The catch is that sometimes both columns have NaN values in which case I want the new column to also have Na...
6
Solved
Is there a way to accomplish the following in one call:
Model.objects.get(id=1) else None
The only way I've found a way to do this is by doing:
try:
object = Model...
except:
object = None
...
Callisthenics asked 3/6, 2012 at 1:3
12
Solved
What does TypeError: 'NoneType' object is not iterable mean? Example:
for row in data: # Gives TypeError!
print(row)
9
Solved
I have a method that sometimes returns a NoneType value. So how can I question a variable that is a NoneType? I need to use if method, for example
if not new:
new = '#'
I know that is the wrong...
1
from dataclasses import dataclass
@dataclass
class InventoryItem:
"""Class for keeping track of an item in inventory."""
name: str | None = None
unit_price: ...
Gametophore asked 18/7, 2023 at 12:20
3
Any help on the following error? I'm running both PCA and t-SNE and PCA seems to run well, but wherever I run t-SNE, I run into the following error.My code for t-SNE is below:
def T_SNE(X,Label,Com...
Beeswax asked 8/8, 2022 at 19:29
9
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...
Holy asked 8/8, 2012 at 18:53
5
I'm trying to assign None to a key in a dict, but I'm getting a TypeError:
self._rooms[g[0]] = None
TypeError: 'NoneType' object does not support item assignment
My code is here:
r = open(filename...
Chirography asked 16/5, 2012 at 13:28
2
Often when I try using BeautifulSoup to parse a web page, I get a None result from the BeautifulSoup function, or else an AttributeError is raised.
Here are some self-contained (i.e., no internet a...
Automatize asked 26/3, 2023 at 5:6
1
If your question was closed as a duplicate of this, it is because you have some code of the general form
x = X()
# later...
x = x.y()
# or:
x.y().z()
where X is some type that provides y and z met...
Lonesome asked 27/3, 2023 at 0:18
2
after execute :
df =pd.pivot_table(data_frame, values='volume', index=['marque'], columns=['canaux_vn_argus','annee'], aggfunc=np.sum, fill_value=0)
I have this Exception:
'NoneType' object is not ...
Flemish asked 26/1, 2022 at 14:36
2
Solved
I am learning and playing around with Python and I came up with the following test code (please be aware that I would not write productive code like that, but when learning new languages I like to ...
Handyman asked 9/12, 2022 at 12:34
13
Solved
I'm getting this error when I run my python script:
TypeError: cannot concatenate 'str' and 'NoneType' objects
I'm pretty sure the 'str' means string, but I dont know what a 'NoneType' object is...
7
Solved
I have table x:
website
0 http://www.google.com/
1 http://www.yahoo.com
2 None
I want to replace python None with pandas NaN. I tried:
x.replace(to_replace=None, value=np.nan)
But I got:
Ty...
8
Solved
I'm trying to count things that are not None, but I want False and numeric zeros to be accepted too. Reversed logic: I want to count everything except what it's been explicitly declared as None.
E...
Groping asked 2/4, 2015 at 21:21
1
anyone can help?
Here are my codes.
df_ci = pd.DataFrame(df_ig.groupby(['Tanggal'])['INTERACTIONS IG'].sum())
df_ci
It is what the dataframe looks like.
INTERACTIONS IG
Tanggal
2021-12-02 74.0
202...
6
Solved
My editor warns me when I compare my_var == None, but no warning when I use my_var is None.
I did a test in the Python shell and determined both are valid syntax, but my editor seems to be saying...
Arrowroot asked 9/1, 2013 at 22:6
15
Solved
I need a way to get a dictionary value if its key exists, or simply return None, if it does not.
However, Python raises a KeyError exception if you search for a key that does not exist. I know that...
Brouwer asked 25/5, 2011 at 20:49
5
def foo(
hello: str='world', bar: str=None,
another_string_or_None: str|????=None):
pass
I'm trying to set a type hint in Python in a function, you can add more than one type hint with somethi...
Radiance asked 5/10, 2013 at 20:54
4
Solved
What I am trying to do here is add the image to the button I have, then based on click or hover change the image. All the examples I have followed use the .config() method.
For the life of ...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.