When I try to translate text using the googletrans module, I get an error: Here’s my code: My code is very simple and I can’t figure out what’s wrong with it. I tried changing the network connection, but it made no difference. Is there any way to fix this problem? It would be great if anyone could help me out.
Creating a timer with tkinter
I am creating a GUI that needs to have timer starting from 0 and counting up every second until it reaches a limit This is the code I have right now Right now this is increasing the score each second but it does not open the GUI until the score reaches the limit. How can I make it so the
Comparing two lists with specific values to read
I have two lists and when I loop through the list and I managed to get the difference, but I need time as well because it is a separate item and ‘uvz’ does not mean to me anything in the list with a few thousand entries. I tried to convert it to the dictionary, but it overwrites with the last
How to create a function which Iterates over multiple lists
So I’m creating a series of column mappings, I can do this manually like so The function produces a mapping of a value and its column. Great, now I want to make this more general. Currently, if I needed to map 2 columns for example I run the following: Works as well but not ideal if I have a lot
Changing values of one column based on the other three columns in pandas dataframe
I have a following Pandas dataframe, where I want to change a value of ‘fmc’ column based on ‘time’, ‘samples’ and ‘uid’ columns. Concept is as following: For the same date, if df.samples == ‘C’ & df.uid == ‘Plot1’, then corresponding row value of fmc * 0.4 similarly for the same date, if df.samples == ‘C’ and df.uid == ‘Plot2’,
More elegant way to call arbitrary Python functions from Flask
Setting up a Flask REST API is easy. I use the following approach: In this example I import functions sitting inside utility.py: This allows me to pass any function name as an argument and get the result back. So if I ran the following in my browser: I would see: The way I process the request is quite bloated. You
Reading file and counting repeated elements automation
I need help to solve a problem quickly. At work I have a file that has 18 characters per line (there are more than 600 lines). I need to read each line and on each line read 6 characters at a time. And in these 6 characters I want to count how many times it is repeated in this file.
Two DataFrames, find index of second one where values of two columns match up from first
I have two pandas DataFrames as pictured. DF1: DF2 (192 x 7): I want to find the index value of DF2 where df1[0] & df1[1] match df2[0] & df2[2]. For more detail, this would be represented above as starting at index 3188 of DF2. DF1 values will be dynamically changing as DF2 stays constant. Edit: Just noticed that there was
Filter out dataframe based on values being within the 90th percentile
Suppose I have this dataframe Now I want to go through each column and filter out the low percentiles keeping only values that are contained in the 90th percentile. Thus since apple and bob are each within their associated 90th percentiles I would have this dataframe How do I achieve this? Answer Hope this helps: Calculate 90th percentile and keep
Are certain words forbidden as keys in a dict() statement?
So I was getting carried away after finishing my function to convert user time strings to seconds when I decided to extend my conversion dictionary with the statement: This fails. I can assign bs=1e-18, but if I assign as=1e-18 it says SyntaxError: invalid syntax, so I tried escaping the a but no luck. Are there forbidden words in dictionary keys?