import pandas as pd

Read the CSV file

df = pd.read_csv(r'E:\Desktop Content\Project_IITB\submission\train_labels.csv')

Drop the 'score' column

df.drop(['score'], axis=1, inplace=True)

Rename the 'has_oilpalm' column to 'label'

df = df.rename(columns={'has_oilpalm': 'label'})

Modify file names in the first column

for i in range(len(df)): hold = df.iloc[i, 0] hold = hold[0:-8] + hold[-4::] df.iloc[i, 0] = hold

Drop rows after index 15057

df.drop(df.index[15057:], inplace=True)

Display the modified DataFrame

df


原文地址: https://www.cveoy.top/t/topic/pHru 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录