Здравствуйте.
Использую Google Colab
Использую Google Colab
Код:
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import datetime
import types
df=pd.read_excel('/content/drive/My Drive/Выборка1.xlsx')
print(df.dtypes)
DATE_ZVK datetime64[ns]
RIDE_TYPE object
RANG object
DISTRICT_OF_UNIT object
DISTANCE_FROM_UNIT float64
CITY object
DISTRICT object
ADDRES object
OBJECT_CATEGORIE object
OBJECT_NAME object
DATE_FIND datetime64[ns]
DATE_STVOL datetime64[ns]
DATE_LOC datetime64[ns]
DATE_LOG datetime64[ns]
DATE_LPP object
SQUARE_PRIB float64
SQUARE_LOC float64
PERSONNEL float64
STVOL_TYPE object
STVOL_COUNT int64
UNIT object
TECH_TYPE object
T_VIEZD datetime64[ns]
T_PRIBPOJAR datetime64[ns]
T_OKONCHRAB object
T_VOZVRPOJ object
dtype: object
#Ошибка №1:
df['DATE_LPP'].astype("datetime64")
TypeError Traceback (most recent call last)
<ipython-input-19-3eee9877f627> in <module>()
----> 1 df['DATE_LPP'].astype("datetime64")
2 #df['T_OKONCHRAB'].astype("datetime64")
3 #df['T_VOZVRPOJ'].astype("datetime64")
4 #print(df.dtypes)
8 frames
/usr/local/lib/python3.6/dist-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
2048 dayfirst=dayfirst,
2049 yearfirst=yearfirst,
-> 2050 require_iso8601=require_iso8601,
2051 )
2052 except ValueError as e:
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime_object()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
TypeError: <class 'datetime.time'> is not convertible to datetime
Ошибка№2:
df2['DATE_LPP'] = pd.datetime(df2['DATE_LPP'], astype(object))
NameError Traceback (most recent call last)
<ipython-input-18-d8e8b826382c> in <module>()
----> 1 df2['DATE_LPP'] = pd.datetime(df2['DATE_LPP'], astype(object))
NameError: name 'astype' is not defined
Вложения
Последнее редактирование: