Skip to content
Advertisement

Tag: if-statement

How to use pandas apply to replace iterrows?

I am calculating the sentiment value on every row in the dataset based on news headline. I used iterrows to achieve this: However, the processing time is taking too long (>30 minutes runtime and it is not done yet). I have 16.6k rows in my dataset. This is a small section of the dataset: I have read that iterrows is

python to get substring of an excel cell with a condition

I’m trying to concatenate several csv files and create a ‘DATE_TIME’ column based on the specific column ‘NAME’. I apply an IF condition for extract the substring of DATE_TIME from NAME based on the appearance of a string ‘RE’. Here’s my code: My question is at the IF-ELSE statement. They return the same position of the substring, so that I

if statement loops and while loops

I’m trying to create a loop and give clues of the number the user has to guess I first tried if statements and it of course didn’t loop and I tried multiple things this was the best I could come up with but it didn’t exactly work it would keep telling me for example: it was smaller but when it

Advertisement