,可以通过以下步骤实现:
import pandas as pd
from datetime import datetime
data = pd.read_csv('file.csv')
data['datetime_column'] = pd.to_datetime(data['datetime_column'])
data['weekday'] = data['datetime_column'].dt.strftime('%A')
specific_weekday = 'Monday' # 替换为特定的星期几
data['is_specific_weekday'] = data['weekday'] == specific_weekday
完整代码示例:
import pandas as pd
from datetime import datetime
data = pd.read_csv('file.csv')
data['datetime_column'] = pd.to_datetime(data['datetime_column'])
data['weekday'] = data['datetime_column'].dt.strftime('%A')
specific_weekday = 'Monday' # 替换为特定的星期几
data['is_specific_weekday'] = data['weekday'] == specific_weekday
这样,你就可以通过判断is_specific_weekday
列的值来确定字符串是否是特定的星期几了。
推荐的腾讯云相关产品:腾讯云云服务器(CVM)和腾讯云数据库(TencentDB)。
领取专属 10元无门槛券
手把手带您无忧上云