解决bug:SettingWithCopyWarning

Convert string type (date) into experiment type data

The original code can be run on someone else’s computer, but it won’t work with me

Error prompt: The
Insert picture description here
original code is as follows (some people may not report an error when using this code):
Insert picture description hereSolution:
Use the copy() function
Use loc to extract the column, the format is:
.loc[row name, column name] = value

The modified code is:
Insert picture description here
code block:

x = airline_selection.copy()
x.loc[:, 'LOAD_TIME'] = pd.to_datetime(x.loc[:, 'LOAD_TIME'])   
x.loc[:, 'FFP_DATE'] = pd.to_datetime(x.loc[:, 'FFP_DATE'])     
L = x.loc[:, 'LOAD_TIME'] - x.loc[:, 'FFP_DATE']

show result:
Insert picture description hereInsert picture description here

Guess you like

Origin blog.csdn.net/weixin_44293949/article/details/105139625