是否有一种简单的方法可以将数据帧中的毫秒转换为不带年,月和日的日期时间?
我已经成功地将毫秒列转换为日期时间。但是,我想摆脱年,月和日。
我这样做了:
df['Laptimes'] = pd.to_datetime(df['milliseconds'], unit='ms')
但是我的值现在被格式化为:"1970-01-01 00:01:38.109"
。
我想拥有:"01:38:109"
答案 0 :(得分:0)
只需在datetime对象上调用time()方法:
Option Explicit
Public Sub DeleteRows()
Dim LastRow As Long
LastRow = pertes.Cells(pertes.Rows.Count, "A").End(xlUp).Row
Dim RowsToDelete As Range '… to collect all rows
Dim i As Long
For i = 2 To LastRow 'forward or backward loop possible
If Not IsDate(pertes.Cells(i, 3).Value) Or IsEmpty(pertes.Cells(i, 3).Value) Then
If RowsToDelete Is Nothing Then 'collect first row
Set RowsToDelete = pertes.Rows(i)
Else 'add more rows to that range
Set RowsToDelete = Union(RowsToDelete, pertes.Rows(i))
End If
End If
Next i
RowsToDelete.Delete 'delete all rows at once
End Sub