So I have a really long string from a text document made entirely up of 7-letter words. I need to separate them and store each 7-letter word into an list. The text document is originally made up of 7-letter words each separated by lines. A small part of it is shown below: Screenshot of the text document After…
Tag: python
Multiple errors when scraping premier league tables
I am learning web-scraping. I succeeded scraping top youtubers ranking with this as reference. I am using the same logic to scrape the PL ranking, but having two issues: it is only collecting up to 5th place. it is getting only the first place for the result and then, getting attribute error: Answer The issue…
How to calculate the average R square of the company data [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 10 months ago. Improve this question STOCK RETURN I don’t know how to compute the average r squared with individual stock…
How would I go about pasting an array over a 2D array?
The Objective I need to take an array with data that can be displayed in 2 dimensions, and paste it over any part of a 2D array as if it were an image. This function would be similar to the Python library Pillow’s paste function. Example Say I have a 2D array with a size of 5×5, with a default
elif: SyntaxError: invalid syntax
I want to re.search within an if statement but regardless of identation, get syntax error. Is it because elif: has no condition? error message Answer In elif you have if, it requires a condition and you provide none, it should be Using walrus operator (since py3.8) you can improve your code to look like If th…
Use “for loop” to create newly named variables from the keys of a dictionary
I want to use a for loop to create newly named variables from the keys, which can then be retrieved globally down the road. To define the variable before with None, has unfortunately brought nothing. Also, with Global I did not get further, but possibly I used it also wrong. I have googled a lot, but unfortun…
Pandas chart using plotly.graph_objects DO NOT ALLOW FOR ‘c’ or ‘color’ ATTRIBUTE
I am adding line charts to an OHLV plotly, but I do not manage to color them. The above code fail when I use ‘color’ as a ‘figg.add_scatter’ attribute : Error given is: WHEN I do not specidy the color of the the scatter lines, the program works fine. Bellow is a data sample: I would li…
Plotly Text Annotation shows the same text throughout
I am trying to show the text on the bars based on some filtered data but the text shows the same value for the last item in the list. I can’t seem to find out what the issue is because display_texts itself gives me what I expect Answer You should remove texttemplate=display_texts and add text=display_te…
How To give optional parameter in DRF
Hi Everyone i am created one api, where i will use [city] as first parameter to get result based on city, but i need [id] also as second parameter but [id] is optional, same time we use [id] as second parameter and sometime not, please help me out for ex- 1-get data based on city url=127.0.0.1:8000/api/car/ci…
DataFrame has two features how to add a row to split them
I have a DataFrame that contains a column called feature that can have more than one of them as illustrated in the image below row 3 & 4. How do a add a row to the DataFrame that splits the two features: so for row 3 as an example having: and row 4: so the idea is to add a