I need to make a linear regression and sum all the predictions. Maybe this isn’t a question for Scikit-Learn but for NumPy because I get an array at the end and I am unable to turn it into a float. I am getting it right up to this point. The next part (which is a while loop to sum all
Tag: python
how to drop rows with ‘nan’ in a column in a pandas dataframe?
I have a dataframe (denoted as ‘df’) where some values are missing in a column (denoted as ‘col1’). I applied a set function to find unique values in the column: I am trying to drop these ‘nan’ rows from the dataframe where I have tried this: However, the column rows remain…
Extract the number before the “am” or “pm”
I want to extract the numbers only from before the “am” and “pm”. If “pm” not avalilable means then only from before “am”. Answer
Unable to determine R library path
I am new to R. I am running Jupyter Lab on a Windows 11 machine, and have created a virtual environment where I installed some packages and irkernel. I get the following message when I execute %load_ext rpy2.ipython: Here is my complete code: Apart from the environment variables, the above code comes from Dav…
Copy a large amount of files in s3 on the same bucket
I got a “directory” on a s3 bucket with 80 TB ~ and I need do copy everything to another directory in the same bucket source = s3://mybucket/abc/process/ destiny = s3://mybucket/cde/process/ I already tried to use aws s3 sync, but worked only for the big files, still left 50 TB to copy. I’m …
Scrapy get only text ignoring the commented content
I researched but can’t find any answers to my question: I want get the main content, ignoring the commented content, how should I do? my scrapy spider looks like: But this codes give me only some nt. plz help, thank you. Answer When /text() in XPath or ::text in CSS fails to produce the desired result, …
KeyError on a certain word
I am trying to use Naive Bayes for spam-ham classification. I am getting a word error repeteadly on here: The error message is just this: ‘hafta’ is the first word of the pandas dataframe and the trainng dataset. I tried the solution on this issue that seemed similar to mine but it didn’t wo…
How to fix IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or delete on table “users” violates foreign key constraint
I have two tables created with Flask-SQLAlchemy below – they have a one to one relationship. I would like to update the user table in a case when the user would like to have a new username: The db.session.commit throws the following error: The error says the logo table still has the old username but I h…
Is there a way to write a python function that will create ‘N’ arrays? (see body)
I have an numpy array that is shape 20, 3. (So 20 3 by 1 arrays. Correct me if I’m wrong, I am still pretty new to python) I need to separate it into 3 arrays of shape 20,1 where the first array is 20 elements that are the 0th element of each 3 by 1 array. Second array is
adding legend to lineplot according to maplotlib’s axvspan
OK, I have this line plot of data trend over this period. Figure: But I want to add legend corresponding to each period (coloured) covereds, such that: 2021-03 to 2021-06 the green area bears the legend spring, 2021-06 to 2021-09 blue area is legend summer, and 2021-09 to 2021-12 (magenta) legend winter. Answ…