Why am I getting KeyErrors when accessing multiple rows in a dataframe?

Why am I getting KeyErrors when accessing multiple rows in a dataframe? Problem Description: I am trying to write the following condition to map MARKET_STATES.OPENING_AUCTION, however I am getting KeyError: (False, False, False) when I run the following: market_info_df.loc[market_info_df[‘issue_status’ == ’10’, ‘market_phase’ == ‘0’, ‘trading_state’ == ‘ ‘].iloc[0]] = MARKET_STATES.OPENING_AUCTION Two questions: What is it … Read more

Python nested loops inside dict

Python nested loops inside dict Problem Description: I have a dict exchange rates. It has 3 levels: rates, date and currency. "rates": { "2022-11-30": { "AED": 0.06019, "AFN": 1.442036, "ALL": 1.836137, "AMD": 6.464451, "ANG": 0.029525, "AOA": 8.304432, "ARS": 2.741601, ……………. etc. I want to write a loop that first will capture the date in a … Read more

filter a DataFrame using complete word only

filter a DataFrame using complete word only Problem Description: I have a large DataFrame (named: complete) of data (only two columns). I want to filter it using complete words only, instead of substrings. Ex: complete dataframe: comment sentiment fast running 0.9 heavily raining 0.5 in the house 0.1 coming in 0.0 rubbing it -0.5 if … Read more

Python selenium Element error event wait function is not helping

Python selenium Element error event wait function is not helping Problem Description: This is my first attempt to login a website using selenium, i have written the below piece of code but not able to login the website, getting the following error message. Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="txtUsername"]"} (Session info: … Read more

Python web scraping script does not find element by css selector

Python web scraping script does not find element by css selector Problem Description: I’m trying to get this web scraper to get current electricity price from this website, it’s in finnish but it’s right under "Hinta nyt". https://sahko.tk/ Here’s my code: import requests from bs4 import BeautifulSoup url = "https://sahko.tk/" element_selector = "" response = … Read more

Shadow name error and Local variable not used

Shadow name error and Local variable not used Problem Description: self teaching myself how to code and starting with this book and a Udemy course. have been working on this practice project for 2 days now and I keep running into "Local variable ‘streaks’ not used when I have the streak counter placed inside the … Read more

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject