FAQ Database Discussion Community

multiple iteration of the same list

python,python-2.7,python-3.x,numpy,shapely
I have one list of data as follows: from shapely.geometry import box data = [box(1,2,3,4), box(4,5,6,7), box(1,2,3,4)] sublists = [A,B,C] The list 'data' has following sub-lists: A = box(1,2,3,4) B = box(4,5,6,7) C = box(1,2,3,4) I have to check if sub-lists intersect. If intersect they should put in one tuple;...

How do I copy a row from one pandas dataframe to another pandas dataframe?

python,python-2.7,pandas,dataframes
I have a dataframe of data that I am trying to append to another dataframe. I have tried various ways with .append() and there has been no successful way. When I print the data from iterrows. I provide 2 possible ways I tried to solve the issue below, one creates...

Python initialize strings as variable

python,python-2.7
I have a calculation schema as string calc = "((k+m+46)/2)" and some strings containing variable like m = 2 k = m*2 all only strings. Now I want to initialize them into Python. my goal is it to calculate with the calculating schema the varible values. calc should return 26...

Problems with MySQLdb python

python,python-2.7,tkinter,mysql-python
When I try connect to mysql with user "root", my application returns "Access denied for user *"ODBC"@"localhost" (using password:NO)"*. I dnt know why this appear. Im using Tkinter like GUI, I tested only Connection's script, its Okay. Code Connection import MySQLdb class Conexao(): def __init__(self, host,user,passwd,db): self.host = host self.user...

How to find longest consistent increment in a python list?

python-2.7
possible_list = [] bigger_list = [] new_list= [0, 25, 2, 1, 14, 1, 14, 1, 4, 6, 6, 7, 0, 10, 11] for i in range(0,len(new_list)): # if the next index is not greater than the length of the list if (i + 1) < (len(new_list)): #if the current value...

Why am I getting a (NameError: name 'self' is not defined ) here using Kivy for Python?

python,python-2.7,kivy,self,nameerror
I'm making a game and I'm working on the screen switching. I want the screen to switch when I press the "play" button but I get a NameError instead. Here's the code: class menu_screen(Screen): def __init__(self, **kwargs): super (menu_screen,self).__init__(**kwargs) menu_layout = FloatLayout logo_label = Label(text = "GAME", size_hint=(.6, .2),pos_hint={'x':.2, 'y':.65})...

lookbehind for start of string or a character

regex,python-2.7,regex-lookarounds
The command re.compile(ur"(?<=,| |^)(?:next to|near|beside|opp).+?(?=,|\$)", re.IGNORECASE) throws a sre_constants.error: look-behind requires fixed-width pattern error in my program but regex101 shows it to be fine. What I'm trying to do here is to match landmarks from addresses (each address is in a separate string) like: "Opp foobar, foocity" --> Must match...

Instagram API Comments Created using Python (ERROR: AttributeError)

python,api,python-2.7,instagram,instagram-api
Hello I trying out Instagram API using python and I am new to it. Hope you guys could take a look at it & help me out. I am wondering how to collect the date & time from users that have commented for each media id. I have tried using...

Why does `for lst in lst:` work? [duplicate]

python,python-2.7
This question already has an answer here: Why can I use the same name for iterator and sequence in a Python for loop? 6 answers The following code lst = ['foo', 'bar', 'baz'] for lst in lst: print lst gives me this output foo bar baz I would expect...

Identifying the nearest grid point

python,python-2.7,numpy
I have three arrays lat=[15,15.25,15.75,16,....30] long=[91,91.25,91.75,92....102] data= array([[ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], ...,...

Pandas Dataframe Complex Calculation

python,python-2.7,pandas,dataframes
I have the following dataframe,df: Year totalPubs ActualCitations 0 1994 71 191.002034 1 1995 77 2763.911781 2 1996 69 2022.374474 3 1997 78 3393.094951 I want to write code that would do the following: Citations of currentyear / Sum of totalPubs of the two previous years I want something to...
{"ft_lang_label":"__label__en","ft_lang_prob":0.79775316,"math_prob":0.80531704,"size":33103,"snap":"2019-43-2019-47","text_gpt3_token_len":8915,"char_repetition_ratio":0.14214931,"word_repetition_ratio":0.020899681,"special_character_ratio":0.28456634,"punctuation_ratio":0.21244492,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":0.96774215,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-24T04:13:02Z\",\"WARC-Record-ID\":\"<urn:uuid:1dc1e3fd-9e92-46ed-a45f-b935275ffad9>\",\"Content-Length\":\"78994\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8c6497df-5d83-48d7-8720-849a84234521>\",\"WARC-Concurrent-To\":\"<urn:uuid:1317688a-c824-40f9-8b6c-755cbdd256ae>\",\"WARC-IP-Address\":\"104.28.3.238\",\"WARC-Target-URI\":\"https://databasefaq.com/index.php/tag/python-2.7\",\"WARC-Payload-Digest\":\"sha1:FJFSJNCKFOG5GKS2ZVUEPYA3OYW6A5SX\",\"WARC-Block-Digest\":\"sha1:AIDWZOCWR7B3LZVTYGGPYLFJC4KW4X2F\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570987841291.79_warc_CC-MAIN-20191024040131-20191024063631-00115.warc.gz\"}"}