[ https://issues.apache.org/jira/browse/FLINK-19894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224397#comment-17224397 ]
Dian Fu edited comment on FLINK-19894 at 11/2/20, 2:36 AM: ----------------------------------------------------------- Fixed in - master via ea43832f2304561d0df29cacbb347182ad03db6f - release-1.11 via 6b1f7e0dde1b89880634baf4836244aba9356691 was (Author: dian.fu): Fixed in master via ea43832f2304561d0df29cacbb347182ad03db6f and release-1.11 via 6b1f7e0dde1b89880634baf4836244aba9356691 > Use iloc for positional slicing instead of direct slicing in from_pandas > ------------------------------------------------------------------------ > > Key: FLINK-19894 > URL: https://issues.apache.org/jira/browse/FLINK-19894 > Project: Flink > Issue Type: Bug > Components: API / Python > Affects Versions: 1.11.0, 1.12.0 > Reporter: Huang Xingbo > Assignee: Huang Xingbo > Priority: Major > Labels: pull-request-available > Fix For: 1.12.0, 1.11.3 > > > When you use floats are index of pandas, it produces a wrong results: > > {code:java} > >>> import pandas as pd > >>> t_env.from_pandas(pd.DataFrame({'a': [1, 2, 3]}, index=[2., 3., > >>> 4.])).to_pandas() > a > 0 1 > 1 2 > {code} > > This is because direct slicing uses the value as index when the index > contains floats: > > {code:java} > >>> pd.DataFrame({'a': [1,2,3]}, index=[2., 3., 4.])[2:] > a > 2.0 1 > 3.0 2 > 4.0 3 > >>> pd.DataFrame({'a': [1,2,3]}, index=[2., 3., 4.]).iloc[2:] > a > 4.0 3 > >>> pd.DataFrame({'a': [1,2,3]}, index=[2, 3, 4])[2:] > a > 4 3{code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)