data = datadropSub IndustryCompany NameNumber of PunishedFinancial Penalty axis=1dataDate = pdto_datetimedataDatedatayear = dataDatedtyeardatamon = dataDatedtmonthdatadayofweek = dataDatedtdayofweek
The given code is performing the following operations:
- Dropping the columns 'Sub Industry', 'Company Name', 'Number of Punished', 'Financial Penalty' from the dataframe 'data'.
- Converting the 'Date' column to datetime format using the pd.to_datetime() function.
- Extracting the year from the 'Date' column and creating a new column 'year' in the dataframe.
- Extracting the month from the 'Date' column and creating a new column 'mon' in the dataframe.
- Extracting the day of the week from the 'Date' column and creating a new column 'dayofweek' in the dataframe
原文地址: http://www.cveoy.top/t/topic/hCXr 著作权归作者所有。请勿转载和采集!