I have a pandas dataframe that has a column like this : I want to make a condition on the whole dataframe based on the id value. I did many attempts but failed. it says key error, it cannot access ‘id’ which is inside the column ‘platform’. Any help is welcome, and thank you in advance…
Tag: python-3.x
Need to run the code again if it fails, is there anyway out?
i have written a selenium automation code however it is very unstable because of the Salesforce website , i need some expertise in my code. i wanted to know how i can re run the code if it fails. below is my code , i will not able able to share some part of my code. i was trying to
how to get data from text file and rewrite to another from
hello beautiful people so i have a text file like this : user = user447 pass = 455555az type = registred date = 1 year and i want to read the file and rewrite it like this user|pass|type|date, line by line, i tried so many ways , i seem stuck since i have to deal with 1 million account Answer
How do I update column description in BigQuery table using python script?
I can use SchemaField(f”{field_name}”, f”{field_type}”, mode=”NULLABLE”, description=…) while making a new table. But I want to update the description of the column of the already uploaded table. Answer Unfortunately, we don’t have such a mechanism available yet to up…
Superscripting a string in python
Hello I am trying to superscript a string for a plot. And the result i get is: The “-0,2*x” should be superscripted. What am I doing wrong? Thank you! Answer It IS making the – a superscript. To get the whole expression in there, you need to enclose the whole expression in curly braces. Sinc…
Can you yield from a lambda function?
I have a generator function in a class: In another function I initalize it as a variable: And it’s yielded as necessary: Can defining the generator be done in one line, however? I’ve considered the below: Here’s a minimal code I’m working with: Output is below: I just wanted to see if …
How to get SHAP values for each class on a multiclass classification problem in python
I have the following dataframe: For which I want to run a classification algorithm in order to predict the 3 classes So I split my dataset into train and test and I run an xgboost Now I would like to get the mean SHAP values for each class, instead of the mean from the absolute SHAP values generated from this
Python – Checking if the data in the files is the same
I have two lists where I have the same number of files. The files in both folders have the same names, for example: and so on. In the test2 folder I have the same named files. How can I compare for each file if the data in both files is the same? So whether: Are you able to advise something?
Automatically and continuously copy files of a certain extension created in source folder and not present in output with Python
I have a program that creates .jpegs in a folder and deletes them after a very short time. I’d like to automatically copy those files to another folder as they are created and before they are deleted. I tried using robocopy but couldn’t manage. How can I do this with Python? Answer this script ana…
Python confusion with return value in try-except-finally
Here is a piece of my code: The returning value is 1 instead of 2, this does not make a lot of sense for me. I thought it would return 2 since finally should execute before returning the value. Can someone help me to understand this? Answer You’re running into the difference between an identifier and a …