Skip to content

Tag: python

How to extract all uppercase row to a new data frame

I have a pandas data frame which looks like this Name Index1 Index2 AAA 67 70 Aaa 55 80 Abb 32 20 BBB 84 45 Baa 80 70 Bbb 13 40 where some rows have names with all uppercase and some with lowercase. How can i create another dataframe with only the uppercase rows expected output will be : Name

Extract full text from different tags and outside them

I want to extract all text information from the already scrapped readme files from github. There is text between Html tags but there is also a lot of text outside (between) tags. Tags are different because those are different readmes so the authors do not follow any particular rules. I want to extract text fr…

Is there a performance deficit not splitting endpoints in Flask?

Just a question as to whether, for example, the following code would be faster in the second format rather than the first. Currently I am using the first example (with around 10 different options) and am wondering whether it would improve performance to split up the end point as in the second example. First e…

Check values greater than int with condition Pandas

Say, I have this dataframe: t = pd.DataFrame(data={“Pos”: [1, 2, 3], “A”: [10, 2, 90], “B”:[90, 98, 10]}) I would like to know which of the (values in A and B >= 20) but only if (Pos = 1 or 3). The result should look like this: I can find the values >= 20 using t[[&#8…

Mutiple style for one DataFrame issues

I would like to understand how “style” works in python, I always have the same error : AttributeError: ‘Styler’ object has no attribute …. for now, I manage to have : the first row in yellow but not the conditional formatting (df_x0) and the conditional formatting blue and orange…

How to terminate wait_for() when a condition is no longer met?

My discord.py command for a bot is supposed to activate a while loop under the condition that a specific variable has a certain value (with a wait_for() coroutine within it): It only executes while cond is True, however cond can change while wait_for() is running (I used a global variable for the example), an…