I am about to decide on programming language for the project. The requirements are that some of customers want to run application on isolated servers without external internet access. To do that I need to distribute application to them and cannot use SaaS approach running on, for example, my cloud (what IR…
Python: Dynamically growing CSV
I am building a CSV chunk by chunk using the csv module from the standard library. This means that I am adding rows one by one in a loop. Each row that I add contains information for each column of my dataframe. So, I have this CSV: And I am adding rows one by one: And so on. My problem
Can One Replace or Remove a specific key from functools.lru_cache?
I’m using a functools.lru_cache to serve temp file paths given certain input*. However in case the path no longer exists, I would like to remove/replace the single corresponding key. The cache_clear() method would be overkill and cache_info() do not appear to help. Thanks for your help! * The method bei…
Calculate the accuracy every epoch in PyTorch
I am working on a Neural Network problem, to classify data as 1 or 0. I am using Binary cross entropy loss to do this. The loss is fine, however, the accuracy is very low and isn’t improving. I am assuming I did a mistake in the accuracy calculation. After every epoch, I am calculating the correct predi…
How to add values to a new column in pandas dataframe?
I want to create a new named column in a Pandas dataframe, insert first value into it, and then add another values to the same column: Something like: How do I do that? Answer Dont do it, because it’s slow: updating an empty frame a-single-row-at-a-time. I have seen this method used WAY too much. It is …
Instance error in OOP design: Instance of Card has No points member
I’m reading this book called Master Object Oriented programming Python by Steven Lott. I came across this code: I’m not able to understand how can self._points() in Card be legal expression. I run the code in compiler too it stats the following error Instance of Card has No points member Full Code…
service account does not have storage.objects.get access for Google Cloud Storage
I have created a service account in Google Cloud Console and selected role Storage / Storage Admin (i.e. full control of GCS resources). gcloud projects get-iam-policy my_project seems to indicate that the role was actually selected: And documentation clearly indicates that role roles/storage.admin comprises …
have a pre-loaded directory when using tkinter.filedialog.askdirectory()
I have the following code: imports: main: This creates a gui window that prompts the user to enter a directory, with the text Output dir and then an open entry window with a Browse button to load the directory The following is get_ouput_directory() function: The idea is: First time user runs this, the entry w…
How to rename the rows in dataframe using pandas read (Python)?
I want to rename rows in python program (version – spyder 3 – python 3.6) . At this point I have something like that: Before that i wanted to rename my columns: It gave me something like that. But now, I want to rename rows. I want: How can I do it? The main idea is to rename every row
pip3: bad interpreter: No such file or directory
I am trying to install dependencies using pip3 command current scenario: I have no idea why my pip3 command is not working. I have tried things like this: Answer You’ve got a whole slew of different Python installations, plus at least one former Python installation that you deleted. Situations like this…