I have created an automated data client that pulls data from a txt file and inputs it into a csv file. Each data entry contains a timestamp, but it is not in the format I need it in, I need it to match the datetime.now() format: ORIGINAL FORMAT [03/11/22 01:06:09:190] DESIRED FORMAT 2022-11-03 01:06:09.190000 I am currently using the following
Tag: variables
Get variables from function input and text after
So id like to make varibles from my function input So basically, the if statement should check if the varible is True or not. And i want to use the function input + ”-outcome” to check. Here is an example, to make you understand my problem better! I’ve tried to find a solution but don’t find it anywhere Thanks! Answer
Why can’t I use my local variable despite already returning it?
It says I haven’t defined the variable even though the code that does that is literally right above it, the error message appears: “Traceback (most recent call last): File “main.py”, line 55, in if kategoribmi == “underweight”: NameError: name ‘kategoribmi’ is not defined” I’m really unsure what to do here, I’ve tried looking up how to fix this but I’m
After complement function can’t print a string, and no error message is shown
rookie here. Can anyone tell me what is wrong with this? I cant seem to print my “primer” string, I am sure that the “region” variable is not empty for I tested it out already. enter image description here Answer In the future, please post the text of your program, not an image of the program. I modified your program
Solving for an unknown variable in python
I’m currently trying to create a body mass index calculator that gives you your BMI and then calculates the difference in weight needed to be at a healthy weight. The equation I’m using to find the BMI is: Using sympy, I’m trying to find how many pounds need to be gained or lost to be within the 19-24 BMI range.
exporting DF to csv with variable file names
I would like to keep this same code but adjust the .to_csv section to save a variable repeating file name I would like the names of the exported files to look like this…I think I need some sort of loop? Period 1 layer 1.csv Period 1 layer 2.csv Period 1 layer 3.csv Period 1 layer 4.csv Period 1 layer 5.csv
Python: How do I pass name of a dataframe to a function in a for loop?
I want to send DF2 to DFn to matchparts function.. I tried sending it using matchparts(DF1, “DF”+ str(cnt)) the function recieves it as string rather than a DF Answer There are basically 3 ways in which you can do this : Using dictionary Using globals() Using eval(Not recommended) Say you have dataframe in multiple variables, say DF1, DF2, DF3. Using
Python variable file path and string prefixes
Using tkinter to select output folder for processed files. Would like to use file_output and x as variables for my file path, My attempt: This does not work in my program. The output I need is I am reading the docs https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-stringprefix Still don’t understand how to escape or a workaround, Help would be much appreciated. Answer you can easily
Class variables not callable?
I’ve stumbled on what is probably a simple issue but I struggle to think of a solution. If I try to make a class variable that equates to a number or an array index they come up with these errors and This seems odd since I can set variables equal to ints and arrays elsewhere. What am I missing and
Python local variable to global variable
I’m trying to write a modular script, with functions -Function 1 age = input(“tell me your age : “) -Function 2 weight = input(“tell me your weight : “) -Function 3 birthday = input(“tell me your birthday : “) at the end, i want to send a mail outside functions like : mail_body = age + weight + birthday Thanks