Skip to content

Resample method doesn't round timestamps with prime numbers frequency #8371

New issue

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

Closed
mapsa opened this issue Sep 23, 2014 · 1 comment · Fixed by #8372
Closed

Resample method doesn't round timestamps with prime numbers frequency #8371

mapsa opened this issue Sep 23, 2014 · 1 comment · Fixed by #8372
Labels
Bug Datetime Datetime data dtype Resample resample method
Milestone

Comments

@mapsa
Copy link

mapsa commented Sep 23, 2014

Hi,

I've found this issue when I tried to resample at different frequencies. When the frequency is a prime number, the first timestamp is not rounded and it takes the first timestamp in the file. Do I need an extra parameter to round timestamps?

csv = r"""Date,Time,Ask,Bid,AskVolume,BidVolume
11-08-2014,00:00:01.093,1.34046,1.34042,1.25,1.69
11-08-2014,00:00:02.159,1.34047,1.34043,4.69,1
11-08-2014,00:00:02.667,1.34046,1.34042,1.32,2.44
11-08-2014,00:00:03.175,1.34046,1.34043,1.32,1
11-08-2014,00:00:07.058,1.34046,1.34043,3.75,1.69
11-08-2014,00:00:07.362,1.34043,1.34041,2.25,1
11-08-2014,00:00:08.324,1.34043,1.34042,1.5,1
11-08-2014,00:00:08.830,1.34045,1.34043,2.44,1
11-08-2014,00:00:08.982,1.34043,1.34041,3,1.69
11-08-2014,00:00:09.815,1.34042,1.34041,1,1
11-08-2014,00:00:10.540,1.34043,1.34041,2.63,1
11-08-2014,00:00:11.061,1.34043,1.3404,7.99,2.25
11-08-2014,00:00:11.617,1.34042,1.34041,1.13,1
11-08-2014,00:00:13.607,1.34043,1.3404,7.5,3.19
11-08-2014,00:00:14.535,1.34043,1.34041,5.25,1
11-08-2014,00:00:15.525,1.34043,1.34041,3.38,1.25
11-08-2014,00:00:17.960,1.34043,1.34041,4.5,1.25
11-08-2014,00:00:20.674,1.34042,1.3404,1.13,2.07
11-08-2014,00:00:21.191,1.34041,1.3404,1,1"""
filename = 'sample.csv'
f = open(filename, 'w')
f.write(csv)
f.close()
df = pd.read_csv(filename, parse_dates={'Timestamp': ['Date', 'Time']}, index_col='Timestamp')
print df.resample('6s', fill_method='bfill')
print df.resample('7s', fill_method='bfill')
print df.resample('11s', fill_method='bfill')
print df.resample('13s', fill_method='bfill')
print df.resample('17s', fill_method='bfill')

Thanks,
Paola

@jreback
Copy link
Contributor

jreback commented Sep 23, 2014

have a look at PR #8372

I am not entirely sure WHY it was doing this a-priori, maybe need some more test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants