Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19894

Use iloc for positional slicing instead of direct slicing in from_pandas

    XMLWordPrintableJSON

Details

    Description

      When you use floats are index of pandas, it produces a wrong results:

       

      >>> 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
      

       

      This is because direct slicing uses the value as index when the index contains floats:

       

      >>> 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

       

      Attachments

        Issue Links

          Activity

            People

              hxbks2ks Huang Xingbo
              hxbks2ks Huang Xingbo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: