I try to make a little text based rpg with python. And the first thing that I want to make is an input to equip armor or weapons. So here is the problem: my function find_armor is not calling whatever I enter. If my first word is “equip” the output is always: your armor: 0 0 Answer In a function,
Extracting specific string matches from a Stock Website page
I am trying webscrape stock market caps, using this below code. At first I traditionally tried to fetch the list of market cap values using bs4. When I used print(x.find(‘span’,{‘class’: ‘Trsdu(0.3s)’}).text) to do this, I got AttributeError: ‘NoneType’ object h…
API web data capture
I am attempting to pull golf stats for an analysis project. TL;DR summary: Should I scrape or use a loop with API I found in network console? I want to pull data for 6 or 7 stat categories, by year(2015-present), and preferably by tournament to better categorize player tournament performance. Base Url is: htt…
ValueError could not convert string to float: ”
I’m having my app on heroku. I use timeme js to record user’s active time spend on the page, and use a hidden form to store the value into the database. Additionally, I’m using otree package to write my app. The following is the code I use: models.py views.py/pages.py in otree html The error…
pivot table raise error uniquely valued index error
I am trying to modify the following dataset in python 3/pandas into a dataframe that will have the first columns or index to be the rank and the second column all the Maj value. Something like that: … I am trying to do that with a table pivot: But get the following error: But i do not have any duplicate…
Error when trying to set column as index in pandas dataframe
I have the following code: which works fine until I do (trying to set column ‘idx’ as in index for the dataframe) which throws an error What does this mean ? Answer The error is when you create A with If you print A.columns you will get: So ‘idx’ is not really in your column for you to…
Last element of list not being taken into account for if statement
I’m an absolute beginner at python and I need to write a code which can differentiate between 2 lists. Overall code works yet, consistently the last element of the list is not being taken into account and lists such as “AT, AC” are being considered the same. I would love some help. Thanks ! …
Mocking FastText model for utest
I am using fasttext models in my python library (from the official fasttext library). To run my u-tests, I need at some point a model (fasttext.FastText._FastText object), as light as possible so that I can version it in my repo. I have tried to create a fake text dataset with 5 lines “fake.txt” a…
Creating requirements.txt in pip compatible format in a conda virtual environment
I have created a conda virtual environment on a Windows 10 PC to work on a project. To install the required packages and dependencies, I am using conda install <package> instead of pip install <package> as per the best practices mentioned in https://docs.conda.io/projects/conda/en/latest/user-guid…
Trying to merge different files csv and to label the columns
I’m trying to get a single dataset by merging several cvs files within one folder. So I would like to merge the different file, which each have 4 columns. I would also like to label the four columns using names=[] in pd.concatenate. I’m using this code: The problem is that instead of getting 4 col…