I'm having trouble making column into a date time column when I have a column with Minutes and Seconds (example, 210:39:00 ,29:23:00) I have no interest in converting into hours, as it would make very little sense to do so within the context of the purpose of the code. Everything I have found is converting the minutes into hours, Id like to keep a format with just minutes and seconds. From the example "210:39:00" the first number is total minutes, the second number is seconds, the last number is nano seconds. it is a string currently; I would convert to a datetime column with the format %M;%S:%f. I have found no way to do this without transforming the first number which is minutes to hours. I would like to keep total minutes and seconds
If you're trying to store this in a Datetime in the DB then this isn't really a feature of this type. I would suggest either storing a minutes and seconds column as an int or maybe storing total seconds, then in your code doing the maths to create whatever you are displaying
Related
I have a dataset that looks as follows:
What I would like to do with this data is calculate how much time was spent in specific states, per day. So say for example I wanted to know how long the unit was running today. I would just like to know the sum of the time the unit spent RUNNING: 45 minutes, NOT_RUNNING: 400 minutes, WARMING_UP: 10 minutes, etc.
I know how to summarize the column data on its own, but I'm looking to reference the time stamp I have available to subtract the first time it was on, from the last time it was on and get that measure of difference. I haven't had any luck searching for this solution, but there's no way I'm the first to come across this and know it can be done some how, just looking to learn how. Anything helps, Thanks!
I have a program that outputs flight time but sometimes it's less than an hour and in that case I don't want a 0 hour displayed.
I could use an if statement for one that has hours and one that doesn't but that doesn't seem efficient. Also would be nice if minutes is zero don't display minutes either.
landed_time_msg = time.strftime("Apx. flt. time %-H Hours : %-M Mins. ",time.gmtime(self.landed_time))
Hoping someone with some openpyxl or general Excel experience might be able to help.
I'm working on a project to record flying hours, and produce an Excel spreadsheet of flights completed in a month.
So far, I've used PySimpleGUI to create a nice front end, and got it working so it stores each flight's details as a dictionary, where the keys are terms like the names of the crew, the aircraft registration and so on. Each flight is separately stored in a dictionary for the current month.
To make sure the hours flown make sense, I've used number spinners so they can't get nonsense inputs. Each type of flying hour is recorded as 2 keys, one for hours and one for minutes. So the dictionary has a section with parts like:
'-firstPilotHours-': 1,
'-firstPilotMins-': 30,
'-captainHours-': 1,
'-captainMins-': 30,
.. and so on.
I've managed to get these put into Excel by converting them to strings and the concatenating them with a colon in the middle:
ws1.cell(row=sortieIdent, column=9).value = str(currentMonth[sortie]["-captainHours-"]) + ":" + str(currentMonth[sortie]["-captainMins"])
... so it appears as "1:30" in Excel, which is the way I used to input the data when I ran a manual Excel file for this purpose.
The cell's number format is set as "[h]:mm" to allow me to perform calculations on the values as hours and minutes, so there can be a monthly total shown and so on.
However, this is the point where I'm stuck. I think because I'm converting them to strings, even though they look like "1:30" in Excel, they're being handled in Excel like a string and not an integer. It's not possible to perform any calculations with them. If I overtype them in Excel with "1:30," then they move to the right hand side of the column and start behaving like numbers.
I can't think of any way to get these into Excel in a manner where I can carry out calculations on them. Can anyone help?
I've thought about having separate columns for the hours and minutes, but I can't figure out how to work calculations in that manner either. I also thought about just displaying them as strings as it works now, but doing the calculations in Python; but I can't figure out how to do proper "hours & minutes" calculations within Python.
Hopefully this gives you some insight into Excel's date/time processing.
For a given decimal number that represents date/time...
The left side of the decimal represents the days since 1/0/1900.
The right side of a decimal number represents time.
Practical Example:
The date time I am writing this post is: 24 May 2020 # 8:02pm
Excel's underlying value is: 43975.8347222222
43975 days since 1/0/1900 = 24 May 2020
.8347222222 = Decimal portion of 24 hours
Having that foundation down (let me know if it isn't clear).
Now we can tackle your example.
To express 1:30 into Excel's world.
We would need to turn 1 hour and 30 minutes into a decimal day
Your 1:30 = .0625 in Excel
To show .0625, you can Format the cell as "hh:mm" or whatever you want using the custom format.
Custom Format = Display value to the user
.0625 = Underlying value Excel uses to calculate
Hope this nudges you further down the road.
I'm new to dealing with time-series data/pandas in python. The data in question relates to some physiological data sampled every second.
I have a pandas dataframe (called df_baseline) indexed using datetime which has a frequency of one row every second for about 25 minutes.
e.g.
2016-01-22 14:39:05
2016-01-22 14:35:06
2016-01-22 14:35:07
type(df_baseline.index)
Out[21]: pandas.tseries.index.DatetimeIndex
Data for this project was collected at varying times and dates with start and stop points varying and I want to iterate through several of such files picking up the first 10 minutes of this data and creating averages and other statistics.
I have searched and am getting confused with datetimes, timeseries, periods and timedeltas but the solutions I've found relate to selecting between very specific time ranges using things like df.between_time and such like which I Don't have as each datafile .
Am I approaching this the wrong way? I feel like the solution is staring me in the face. Please get me on the right track!
My users can supply a start and end date and my server will return a list of points between those two dates.
However, there are too many points between each hour and I am interested to pick only one random point per every 15 minutes.
Is there an easy to do this in Appengine?
You should add to each Datastore entity an indexed property to query one.
For example you could create an "hash" property that will contain the date (in ms since epoch) modulo 15 minutes (in ms).
Then you just have to query with a filter saying hash=0, or rather a random value between 0 and 15 min (in ms).