nonetype

Replace None with NaN in pandas dataframe

人盡茶涼 提交于 2020-08-20 17:52:02
问题 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: TypeError: 'regex' must be a string or a compiled regular expression or a list or dict of strings or regular expressions, you passed a 'bool' How should I go about it? 回答1: You can use DataFrame.fillna or Series.fillna which will replace the Python object None , not the string 'None' . import pandas as pd

Replace None with NaN in pandas dataframe

心已入冬 提交于 2020-08-20 17:49:11
问题 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: TypeError: 'regex' must be a string or a compiled regular expression or a list or dict of strings or regular expressions, you passed a 'bool' How should I go about it? 回答1: You can use DataFrame.fillna or Series.fillna which will replace the Python object None , not the string 'None' . import pandas as pd

Kivy: AttributeError: 'NoneType' object has no attribute 'parent' when scroll down and scroll up again in recycle view

巧了我就是萌 提交于 2020-06-17 09:58:07
问题 My Kivy App Description: I have 3 types of widgets in MyFirstScreen : A RecycleView that has multiple "User"s as its items. (each item is a dictionary ) Three TextInput s that are related to values of each recycle view item. (if you select any items of RecycleView these TextInput s will loaded with corresponding dictionary values) An "Add New User" Button . (if you enter NEW values in TextInputs s and press this button, RecycleView will be updated with: previous items + your new item) Issue:

'NoneType' object is not subscriptable?

旧城冷巷雨未停 提交于 2020-01-31 06:58:49
问题 list1 = ["name1", "info1", 10] list2 = ["name2", "info2", 30] list3 = ["name3", "info3", 50] MASTERLIST = [list1, list2, list3] def printer(list): print ("Available Lists:") listlen = (len(list)) for x in range(listlen): print (list[x])[0] This code is returning the "'NoneType' object is not subscriptable" error when I try and run printer(MASTERLIST) . What did I do wrong? 回答1: The print() function returns None . You are trying to index None. You can not, because 'NoneType' object is not

Python: 'NoneType' object is not subscriptable' error [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-30 09:17:25
问题 This question already has answers here : Why do I get AttributeError: 'NoneType' object has no attribute 'something'? (9 answers) Closed 3 months ago . I'm new to databases in Python, so to practice some key skills I'm building a login screen that writes usernames and hashed passwords to the database, and then checks the user's inputs against what's in the database. However, when trying to pull the usernames and passwords from the database and storing them in variables, I keep getting the "

Python: 'NoneType' object is not subscriptable' error [duplicate]

允我心安 提交于 2020-01-30 09:17:21
问题 This question already has answers here : Why do I get AttributeError: 'NoneType' object has no attribute 'something'? (9 answers) Closed 3 months ago . I'm new to databases in Python, so to practice some key skills I'm building a login screen that writes usernames and hashed passwords to the database, and then checks the user's inputs against what's in the database. However, when trying to pull the usernames and passwords from the database and storing them in variables, I keep getting the "

Implementation of NoneType, Reasons and Details

六月ゝ 毕业季﹏ 提交于 2020-01-21 06:35:27
问题 I recently read somewhere that the special value None in python is a singleton object of its own class, specifically NoneType . This explained a lot, since most errors involving None in python produce AttributeError s instead of some special "NoneError" or something. Since all of these AttributeErrors reflected the attributes that NoneType lacked, I became intrigued by what attributes NoneType did have, if any. I decided to look into this NoneType and learn more about it. I've always found

python TypeError: 'NoneType' object has no attribute '__getitem__'

喜欢而已 提交于 2020-01-13 18:57:08
问题 This time I am trying another example from Solem's blog. It's a module that detects lines and circles in an image by using the Hough transform. Here is the code (houghlines.py): import numpy as np import cv2 """ Script using OpenCV's Hough transforms for reading images of simple dials. """ # load grayscale image im = cv2.imread("house2.jpg") gray_im = cv2.cvtColor(im, cv2.COLOR_RGB2GRAY) # create version to draw on and blurred version draw_im = cv2.cvtColor(gray_im, cv2.COLOR_GRAY2BGR) blur =