We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http://stackoverflow.com/questions/28819470/numbers-of-day-in-month?nah=1#28821925 xref #4640
This should be exposed as a vectorized method in tslib (e.g. take in an ndarray of i8 and return an ndarray)
pd.tslib.monthrange is an unadvertised / undocumented function that handles the days_in_month calculation (adjusting for leap years). This could/should prob be added as a property to Timestamp/DatetimeIndex (and to ``.dt``) In [34]: df = DataFrame({'date' : pd.date_range('20120101',periods=15,freq='M') }) In [35]: df['year'] = df['date'].dt.year In [36]: df['month'] = df['date'].dt.month In [37]: df['days_in_month'] = df.apply(lambda x: pd.tslib.monthrange(x['year'],x['month'])[1], axis=1) In [38]: df Out[38]: date year month days_in_month 0 2012-01-31 2012 1 31 1 2012-02-29 2012 2 29 2 2012-03-31 2012 3 31 3 2012-04-30 2012 4 30 4 2012-05-31 2012 5 31 5 2012-06-30 2012 6 30 6 2012-07-31 2012 7 31 7 2012-08-31 2012 8 31 8 2012-09-30 2012 9 30 9 2012-10-31 2012 10 31 10 2012-11-30 2012 11 30 11 2012-12-31 2012 12 31 12 2013-01-31 2013 1 31 13 2013-02-28 2013 2 28 14 2013-03-31 2013 3 31
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
http://stackoverflow.com/questions/28819470/numbers-of-day-in-month?nah=1#28821925
xref #4640
This should be exposed as a vectorized method in tslib (e.g. take in an ndarray of i8 and return an ndarray)
The text was updated successfully, but these errors were encountered: