"Return" a value if a specific Error occurs
I am creating n variables, and whenever a Error occur, i want to give a specific value to the variable.Example:a = "abc"b = 0def lastnext (word, count): last = word[count - 1] next = word[count + 1]...
View ArticleHow do I upgrade python on Mac?
I want to upgrade my version of python on Mac but I just can figure out how to do it.Can I do:pip3 install python3or:pip3 upgrade python3or:pip3 install pythonor:pip3 upgrade python3I tried searching...
View ArticleHow can I see the source code for a python library?
I currently find myself using the bs4/BeautifulSoup library a lot in python, and have recently been wondering how it works. I would love to see the source code for the library and don't know how. Does...
View ArticleHadoop jar command to run python mapper and reducer
I'm trying to run mapper and reducer to get the year and temperature as keys and values from zip files in my folder.I could write the mapper and reducer to print the values. However, I'm not able to...
View ArticleConfusing conversion of types in pandas DataFrame
Suppose I have a list of list of numbers that happen to be encoded as strings.import pandas as pdpylist = [['1', '43'], ['2', '42'], ['3', '41'], ['4', '40'], ['5', '39']]Now I want a dataframe where...
View ArticleError using imap-tools with an email address containing non-ascii characters...
I use imap-tools to access my emails.My problem is that I'm trying to access emails sent from someone whose email contains special characters like ø which I can't encode correctly because from_ accepts...
View Articleapply different formatting to only one bar label in matplotlib's bar label
I want to apply different formatting to only 1 bar label in matplotlib's bar labels.Example Codeimport pandas as pdimport seaborn as snssns.set_style('white')s = pd.Series({'John': 10000, 'Amy': 5000,...
View ArticleError while reading data from csv file using pandas
import yfinance as yahooFinanceimport timeimport datetimeimport pandas as pdticker = 'TSLA'period1 = int(time.mktime(datetime.datetime(2022, 12, 1, 23, 59).timetuple())) # year,month,dateperiod2 =...
View Articleis their any function that i can use to read my csv file without any codec...
Is their any function that i can use to read my csv file without any codec error?import refrom nltk.stem import WordNetLemmatizerimport contractionsimport csvbasicdict = dict()temp_of_colums = []def...
View ArticlePandas read tab separated csv
I have a problem with plotting my load profiles for my Bachelor thesis.I've got a csv file, which is separated by tabs, like this:PV-Energie (AC) abzgl....
View ArticleHow can I modify the serializer.is_valid() method for existing rows on the...
I am trying to insert a list of objects by using serializer.save() but when I try to insert existing data it throws error and doesn't pass the validation how can I modify the is_valid() method or is...
View ArticleSpeed up of Python Inference Pipeline
I´m trying to build a distributed LLM inference platform with Huggingface support. The implementation involves utilizing Python for model processing and Java for interfacing with external systems....
View ArticleHow to scrape table data from HTML?
I have been trying to scrape a table from this website https://www.alphaquery.com/stock/aapl/earnings-historybut in no way I can achieve it. I can t even find the table.import requestsfrom bs4 import...
View Articledistance of a point from the lines that are contained in a list
I am making a python animation for a project in which, I am taking a star shaped boundary in which there are two balls which are moving inside that star. If the balls collide to other balls, a new ball...
View ArticleWhy does ZarrArraySource get an unexpected argument when loading data with...
I am using data from an Earth Model System called nextGEMS, but when I try to load it in VSCode I get the following message:TypeError: ZarrArraySource.__init__() got an unexpected keyword argument...
View ArticleFastAPI with SAM model: Only a few workers load properly due to CUDA memory...
I'm working on a project involving FastAPI with a Segment anything Model (SAM) for image processing. I have a CUDA setup with a GPU (NVIDIA RTX A4000) available for acceleration, and I'm running...
View ArticleCliping netcdf with shapefile
`i want to clip netcdf with shapefile and keep getting errors. i also tried to project it to the same coordinate system, but seems not working. Can you please help me?import xarrayimport geopandasfrom...
View ArticleInspect openai raw network request and response
I'm using Python openai library to make some calls to chat.completions.create and I want to inspect the raw requests and responses alongside with the JSON request body and responses from the model.I...
View ArticleSet up timezone for timezone for all nodes in databricks without init script
I have used this question to set up pyspark timezone using configuration of the cluster withspark.sql.session.timeZone Asia/HongkongThis, unfortunately does not set timezone for all nodes and therefore...
View Articlemy Maximum fonction is not returning me the good number [closed]
Im trying to get the number max of a category of a csv file, but i cant get why my fonction is not workingimport csvfile = open("serieschrono-datagouv.csv", "r", encoding="utf8")reader =...
View Article