date.csv (date is recorded)
date 20200401 20200402 20200405 20200407 20200409
When I met
I want to store it as a number in the list like date_list = [20200401, 20200402, 20200405, ....]. Is there a way to store only the dates excluding Saturdays, Sundays, and holidays at this time?
April 5, 2020 will be Sunday, so the output will be
We expect the result date_list = [20200401, 20200402, 20200407, 20200409].
The current source code looks like the following, simply putting the date columns in order.
import csv import pandas as pd #Date information date_data = pd.read_csv ('date.csv') date_list =  for i, date in enumerate (date_data ['date']): date_list.append (date_data ['date'] [i]) print (date_list)
Answer # 1
import pandas as pd import datetime import jpholiday def weekday (date): dt = datetime.date (int (date [0: 4]), int (date [4: 6]), int (date [6: 8])) d = dt.isoweekday () if jpholiday.is_holiday (dt): return False if d>= 6: return False else: else: return True df = pd.read_csv ('date.csv') df ['date'] = df ['date'] .astype ('str') df ['weekday'] = df ['date'] .apply (weekday) df = df [df ['weekday']] date_list = df ['date']. to_list () # ['20200401', '20200402', '20200407', '20200409']
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory