error-handling

KeyError: 'NOX'

KeyError: 'NOX' Question: Input: import matplotlib.pyplot as plt import pandas as pd import seaborn as sns CO =[] NO2 =[] NOX =[] SO2 =[] FSP=[] RSP=[] O3=[] no=0 f = open(‘Air Pollutants.csv’) data = pd.read_csv(f,encoding=’utf-8′,header=None, sep = ‘t’) NOX=data[‘NOX’] NO2=data[‘NO2’] sns.kdeplot(NOX,shade=True, color="orange") # to make a figure of NOX sns.kdeplot(NO2,shade=True, color="blue") # to make a …

Total answers: 1

AttributeError: 'Robot' object has no attribute 'introduce_self'

AttributeError: 'Robot' object has no attribute 'introduce_self' Question: I’m a beginner in class & objects and was wondering why the line r2.introduce_self had an attribute error with an object that doesn’t have an attribute. class Robot: def __init__(self, rname, rcolor, rweight): self.name = rname self.color = rcolor self.weight = rweight def introduce_self(self): print("my name is …

Total answers: 2

How to log every error in file you get in cmd

How to log every error in file you get in cmd Question: I tried try catch block in my python script but my team lead wants to log every error which can occure i cannot write try catch every line do anyone know better way to do this? currently im using try catch and logger …

Total answers: 1

Removing a specific logger object in python logging

Removing a specific logger object in python logging Question: I am trying to suppress all the elasticsearch logging from my output and keep all the other logging in my code. I have tried setting elasticsearch logging level to warning as it is explained here How to set the logging level for the elasticsearch library differently …

Total answers: 1

"Moving a directory into itself" error in Python

"Moving a directory into itself" error in Python Question: I have an application which sorts files upon receiving the path to the folder containing the files. However, there’s a line of code where I’m supposedly moving a directory into itself, but I can’t see how that’s happening since I’m doing the same thing with the …

Total answers: 1

vscode python URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

vscode python URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known> Question: # requirements import pandas as pd from urllib.request import Request, urlopen from fake_useragent import UserAgent from bs4 import BeautifulSoup ua = UserAgent() ua.ie req = Request(df["URL"][0], headers={"User-Agent" : ua.ie}) html = urlopen(req).read() soup_tmp = BeautifulSoup(html, "html.parser") soup_tmp.find("p", "addy") #soup_find.select_one(".addy") URLError: …

Total answers: 1

C programming recursion segmentation fault

C programming recursion segmentation fault Question: I am trying to using with recursion function. But I got failed which is segmentation fault. #include <stdio.h> int factorial( int x ); int main(){ factorial(4); return 0; } int factorial( int x ){ return x* factorial(x-1); } I have seen the same code in Python and C programming …

Total answers: 2

How to create an if statement program to calculate a tip?

How to create an if statement program to calculate a tip? Question: I’m trying to write a program for my homework: Write a program to determine how much to tip the server in a restaurant. The tip should be 15% of the check, with a minimum of $2. The hint said to use an if …

Total answers: 3

What am I doing wrong with my tic-tac-toe game?

What am I doing wrong with my tic-tac-toe game? Question: I’m making a game similar to tic-tac-toe, called strikes and circles. The most noticeable difference is that the board is 4 by 4, rather than 3 by 3. (I am a beginner with coding in Python so please bear with me.) I took a chunk …

Total answers: 1