#ataB7=dataB7applylambda x 0 if x==#NULL!newB7=for i in dataB7; if i==#NULL!; newB7append0 else newB7appendidataB7=pdSeriesnewB7解释每行代码的意思
-
#ata['B7']=data['B7'].apply(lambda x: 0 if x=='#NULL!'): This line is commented out and not executed. If it were executed, it would create a new column called 'B7' in the 'ata' dataframe and populate it with the values from the 'B7' column in the 'data' dataframe. However, if the value in the 'B7' column of 'data' is '#NULL!', then it would replace it with 0.
-
newB7=[]: This line creates an empty list called 'newB7'.
-
for i in data['B7']: This line starts a for loop that iterates through each value in the 'B7' column of the 'data' dataframe.
-
if i=='#NULL!'; This line checks if the value of 'i' is equal to the string '#NULL!'.
-
newB7,append(0): This line appends the value 0 to the 'newB7' list if the value of 'i' is equal to '#NULL!'.
-
else: This line is the start of an else statement that executes if the value of 'i' is not equal to '#NULL!'.
-
newB7,append(i): This line appends the value of 'i' to the 'newB7' list if the value of 'i' is not equal to '#NULL!'.
-
data['B7']=pd.Series(newB7): This line assigns the values in the 'newB7' list to the 'B7' column of the 'data' dataframe, effectively replacing any '#NULL!' values with 0
原文地址: https://www.cveoy.top/t/topic/hslq 著作权归作者所有。请勿转载和采集!