i just want to give program a url of a playlist and print the title and urls and before titles and urls i want be Ordinal numbers also i new in python i try for loop and while loop an i get list error Answer I think you are missing in “for” loop, you tried to use as index for
Tag: python
How to run a Python module from Linux console?
I am a beginner in Linux and I am trying to do something very basic (yet it does not seem to work). I have installed a python3 package. I wish to run this Python package on a specific folder from my linux machine. The idea is that this package should restructure all my files in a specific format (this is
If statement not executing. Python
I am still new to programming and I wanted to do a simple calculator in python. However, I could only reach this point of my code: Not sure why my if statement is not executing after all the correct inputs from the user. I mostly focused on the error handling part and after everything going well, the if statement is
Plotting values above a threshold in Python
Having issues with plotting values above a set threshold using a pandas dataframe. I have a dataframe that has 21453 rows and 20 columns, and one of the columns is just 1 and 0 values. I’m trying to plot this column using the following code: But get the following errors: Any suggestions on how to fix this? Answer The error
Fill up column based on condition goes wrong
I am trying to fill a column based on condition but something goes wrong. So I am expecting if it is not 2017 there should be a no. But yet the years 2019 and 2020 also get filled up with yes. Does anyone know what went wrong? Answer Use Series.between instead & for bitwise AND, for chain by bitwise OR
Switch pandas data frame to dictionary
I have a pandas data frame of the following shape: MNK Monkey CT Cat GNNPG Guinnea Pig And I want to switch it into such dictionary: {‘MNK’:’Monkey’,’CT’:’Cat’,’GNNPG’:’Guinnea Pig’} Is there a way of doing such transformation (without iterating on rows) ? Answer Calling your DataFrame as df and columns code and `animal, you can declare a dictionary iterating over it.
How do I convert this selenium next button clicking code into loop so I can get url of all the pages until next button disappears
Hello I wrote this selenium code to click Next button and give me url of the next page. The Question is I want to convert this code in a loop so I can click on the next button & collect all URLs until next button disappears. How do I out all the collected URLs in a list? I tried While
Discord.py – How to set slash command parameter’s name and description
I’m trying to make discord bot using python discord.py module, and I wanna add slash command with member parameter using CommandTree. I added parameter but it does not have it’s own parameter name(displays as it’s variable name) and description. How can I add its name and description? Answer You can use the app_commands.describe and the app_commands.rename decorators to do this:
How would I pull out similar value pairs from a dictionary and put them in a new dictionary?
I have a dictionary filled with 3 keys: “Ticker”, “Title” and “Value”. The ticker key contains 100 stock tickers that corresponds to the value of the purchase and title that are in the same position. So here is an example of the dictionary: So “AKUS” corresponds with the 10% and +$374,908,350. I am only showing 4 items in the dictionary
How to combine multiple data frames into a single violinplot and add a swarmplot
I have two data frames, with different shapes. I’d like to plot the two data frame values of the violin plots next to each other instead of overlapping. Here is my output image. But I’d like to get each blue and red violin plot next to each other instead of overlapping. I’d further like to show the datapoints via a