4

I think the answer to your question will depend largely on the operating environment of your Python program. The actual language (Python) is not really relevant here, as it does nothing special in this regard. File management is the responsibility of the OS, and Python, like most programming languages only provides an interface to the underlying OS APIs. ...


3

There are a few small niceties that you can add. long = pd.DataFrame(columns={'bene_id', 'day','date'}) cols_to_order = ['bene_id', 'day','date'] should reuse the list: cols_to_order = ['bene_id', 'day','date'] long = pd.DataFrame(columns=set(cols_to_order)) This: cols_to_order + (long.columns.drop(cols_to_order).tolist()) can drop the outer parens, since ...


2

I know this is a part of an exercise, but it feels like a lot of wheel reinventing where you can leverage builtin Python capabilities for date validation: from datetime import date >>> date(2020, 2, 29) # leap year date works datetime.date(2020, 2, 29) >>> date(2002, 2, 29) # non-leap year will raise ValueError ValueError: day is out of ...


2

I suggest some minor improvements in the regular expression: make sure that the same separator is used between day and month and between month and year with a backreference (?P=sep), replace numbered capture groups with named, and make non-needed groups, if there wer any, non-capturing with ?:. Consequently, finditer and groupdict are used, and the day is ...


1

My solution is similar to some of the others here. However, it doesn't use loops, math, conditional logic, or hard-coded month names. That should make it more resistant to bugs. import calendar from datetime import datetime monthList = lambda month: \ calendar.month_abbr[month:] + \ calendar.month_abbr[1:month] currentMonth = datetime.now().month ...


Only top voted, non community-wiki answers of a minimum length are eligible