I’m trying to use two columns from an existing dataframe to generate a list of new strings with those values. I found a lot of examples doing something similar, but not the same thing, so I appreciate advice or links elsewhere if this is a repeat question. Thanks in advance! If I start with a data frame…
Tag: python
Python datastructure for keys being mapped to auto-increment integer value
I want to store a list of strings into a dictonary data structure, where the key will be the string I provided, and the value will be an auto-increment count. I could do this by keeping a manual counter and then using that when inserting values in a dictionary, but I wanted to know if there is any default dat…
How to select the first character on a string in python then use that first character in an if statement
**This should print “{name} plays banjo” because the name starts with “r” and I suspect that there is something wrong with how I selected the first character of the string and used it in an if statement. ** Answer Python has a string method startswith() which will do what you need. Rep…
Conda is installing a very old version of pytorch-lightning
I tried installing pytorch lightning by runnning: as described here: https://anaconda.org/conda-forge/pytorch-lightning This link seems updated to version 1.6.5 However, when I run this command, an old version of pytorch-lightning is installed, as can be seen here: As you can see, version 0.8.5 is being insta…
How to delete data from database with a button using only DJANGO python, java script, and HTML?
I am working on a django project where my database gets populated from a post call, and for quality of life, I want to be able to clear ALL of the data from the database at the click of a button. If it’s possible, I’d like to only use python, javascript, and HTML. I’ve done some searching on…
INSERT table names using SELECT statement in MySQL
In MySQL, I know I can list the tables in a database with: But I want to insert a table name into a specified table, for example: But when I execute the above statement, the dataset_names table does not get updated. I created the master table using: Here is the python code. Answer Here the order on insert val…
How to remove all non-numeric characters (except operators) from a string in Python?
I would like to remove all non-numeric characters from a string, except operators such as +,-,*,/, and then later evaluate it. For example, suppose the input is ‘What is 2+2?’ The result should be ‘2+2’ – keeping only the operator symbols and numeric digits. How can I do this in …
How to create a list of tokenized words from dataframe column using spaCy?
I’m trying to apply spaCys tokenizer on dataframe column to get a new column containing list of tokens. Assume we have the following dataframe: The code below aims to tokenize Text column: The results looks like: Now, we have a new column tokens, which returns doc object for each sentence. How could we …
Search the data on the text file and Printing in GUI with Tkinter
I am writing a python program to search the data on the text file in GUI The search function normally gives the result (in CLI). I want to use it with Tkinter, but when I pull the input with the Tkinter Entry function, my search function does not work. Whatever I write, it outputs the data in the entire text
Why PyCharm does not recognize user environment variables configuration?
I tried to use the PyCharm user environment variable configuration, however, it throws KeyError. If I try to set the variables via commands it works, but via configuration it does not. I will appreciate any help. Answer OK, apparently for terminal and run, there are different places where you define configura…