I have a list of file directories that looks similar to this: I am trying to remove the beginnings of the paths that are the same from every list, and then deleting that from each file. The list can be any length, and in the example I would be trying to change the list into: Methods like re.sub(r’.*I…
Keras LSTM – why different results with “same” model & same weights?
(NOTE: Properly fixing the RNG state before each model creating as described in comment in comment practically fixed my problem, as within 3 decimals results are consistent, but they aren’t exactly so, so there’s somewhere a hidden source of randomness not fixed by seeding the RNG… probably …
TypeError: expected string or bytes-like object – with Python/NLTK word_tokenize
I have a dataset with ~40 columns, and am using .apply(word_tokenize) on 5 of them like so: df[‘token_column’] = df.column.apply(word_tokenize). I’m getting a TypeError for only one of the columns, we’ll call this problem_column Here’s the full error (stripped df and column names…
Sklearn logistic regression, plotting probability curve graph
I’m trying to create a logistic regression similar to the ISLR’s example, but using python instead But I keep getting the graph on the left, when I want the one on the right: Edit: plt.scatter(x,LogR.predict(x)) was my second, and also wrong guess. Answer you use predict(X) which gives out the pre…
Building a connection URL for mssql+pyodbc with sqlalchemy.engine.url.URL
The problem… I am trying to connect to a MSSql server via SQLAlchemy. Here is my code with fake credentials (not my real credentials obviously). The code… And this is the .pyodbc error that I am getting. Additional Details But, here is what is weird… I if make a pyodbc connection and use Pan…
Validate card numbers using regex python
I have some credit card numbers with me and want to validate them over the below rules. ► It must only consist of digits (0-9) ► It may have digits in groups of 4, separated by one hyphen “-” ► It must NOT have 4 or more consecutive repeated digits ► It may contain exactly digits without any space…
Django: Gmail SMTP error: please run connect() first
I am trying to send mail when a certain query is executed. But I am getting error in the connection. I have tried the following settings in my settings.py file I have executed the following command to send the email: But whenever I run the above code I get ‘please run connect() first’ error. What …
How can I use matplotlib.pyplot in a docker container?
I have a certain setting of Python in an docker image named deep. I used to run python code For information, -v and -w options are to link a local file in the current path to the container. However, I can’t use matplotlib.pyplot. Let’s say test.py is I got this error. With solution search, I am ha…
How to do superscripts and subscripts in Jupyter Notebook?
I want to to use numbers to indicate references in footnotes, so I was wondering inside of Jupyter Notebook how can I use superscripts and subscripts? Answer You can do this inside of a markdown cell. A markdown cell can be created by selecting a cell then pressing the esc key followed by the M key. You can t…
Seconds until end of day in python
There’s another question here that asks how many seconds since midnight – this question is the opposite. How do I get the seconds until the end of the day, from the current time, using python? Answer The cleanest way I found to accomplish this is Taken from http://wontonst.blogspot.com/2017/08/tim…