You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importpandasaspdfromdatetimeimportdatetimeimportpytzimportnumpyasnpimportmatplotlib.pyplotaspltdefconvert_2_datetime(timestamp, timezoneid):
""" :param timestamp: UTC format in milliseconds (data.index.values) :param timezoneid: timezone object from CTX (for example pytz.timezone(ctx.inp.assets[0].properties['timezoneid'])) :return: vector of datetimes """ifisinstance(timestamp,int) orisinstance(timestamp,float):
utctime=datetime.utcfromtimestamp(timestamp/1000).replace(tzinfo=pytz.utc)
output=utctime.astimezone(pytz.timezone(timezoneid.zone))
else:
utctime= [datetime.utcfromtimestamp(i/1000).replace(tzinfo=pytz.utc) foriintimestamp]
output= [i.astimezone(pytz.timezone(timezoneid.zone)) foriinutctime]
returnoutput# minute sampled datav1= [0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0]
data=pd.DataFrame({'v1':np.array(v1)},index=np.arange(start=1,stop=len(v1)+1)*60000)
data['ts']=convert_2_datetime(timestamp=data.index.values,timezoneid=pytz.timezone('UTC'))
data.set_index('ts',inplace=True)
data07=data.resample(rule='700L',closed={'right','left'}).interpolate(method='linear')
data06=data.resample(rule='600L',closed={'right','left'}).interpolate(method='linear')
plt.show()
data07.v1.plot(style='.',label='700 ms')
data06.v1.plot(style='.', label='600 ms')
data.v1.plot(style='x',label='original')
plt.legend()
print('Finish!')
Problem description
In the code above, data07 does not start from the same time data06 (and data) starts. The plot is showing that also the behavior of interpolation on data07 is very different from the one with data06.
I upgraded pandas to the last version but the problem persists.
Code Sample, a copy-pastable example if possible
Problem description
In the code above, data07 does not start from the same time data06 (and data) starts. The plot is showing that also the behavior of interpolation on data07 is very different from the one with data06.
I upgraded pandas to the last version but the problem persists.
This is the link where the question has been asked on Stackoverflow:
https://stackoverflow.com/questions/50724231/pandas-resample-function-issue-from-minute-to-millisecond-ersampling
Expected Output
Expected output should be equal to data06 (interpolation between points of data).
Output of
pd.show_versions()
I tried with 0.19.2 and 0.23.0 (here below I put the output of 0.23.0).
INSTALLED VERSIONS
commit: None
python: 3.6.1.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.23.0
pytest: 3.0.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.14.4
scipy: 0.19.0
pyarrow: None
xarray: None
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: 1.2.1
tables: 3.2.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: