everyone. I am new to python and currently am working on drone development. After each test flight, I will compile all the drone flight info and turn it into a list, including drone no, date, time, battery, GPS etc. csv data format of flight info
From that, I want to generate a automated csv report after each flight for a quick summary. However, when I tried to calculate the flight duration for each flight by using the groupby function. It shows AttributeError: 'list' object has no attribute 'values. how can i fix that? your input will be much appreciated. Code as below:
import pandas as pd
import numpy as np
from datetime import datetime, time, timedelta, date
import time
df = pd.read_csv(r"test.csv")
Time_min = df['Time'].values.min()
Time_max = df['Time'].values.max()
print(Time_max)
print(Time_min)
Time_groupby_max = df.groupby(['Drone no'])(['Time'].values.max())
Time_groupby_min = df.groupby(['Drone no'])(['Time'].values.min())
print(Time_groupby_max)
def calcTime(enter,exit):
format="%H:%M:%S"
#Parsing the time to str and taking only the hour,minute,second
#(without miliseconds)
enterStr = str(enter).split(".")[0]
exitStr = str(exit).split(".")[0]
#Creating enter and exit time objects from str in the format (H:M:S)
enterTime = datetime.strptime(Time_min, format)
exitTime = datetime.strptime(Time_max, format)
return exitTime - enterTime
enter = datetime.today().time()
exit = datetime.today().time()
duration = calcTime(enter,exit)
print(f"Duration is {duration} (Hours:Minutes:Seconds)")