How to access a row from a panda dataframe using index without column header?









up vote
0
down vote

favorite












e.g -



df= A B C
1 2 3
2 4 5
2 1 3


I want to access second row without header



If I do df.iloc[[1]] it is giving me -



 A B C
2 4 5


as output, but I want



2 4 5



as output. No column header is needed and eventually I will store that in list.










share|improve this question



















  • 1




    df.iloc[1].values
    – Alex
    23 hours ago











  • I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
    – jezrael
    23 hours ago











  • Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
    – jezrael
    23 hours ago











  • I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
    – Sayantan
    23 hours ago










  • hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
    – jezrael
    23 hours ago














up vote
0
down vote

favorite












e.g -



df= A B C
1 2 3
2 4 5
2 1 3


I want to access second row without header



If I do df.iloc[[1]] it is giving me -



 A B C
2 4 5


as output, but I want



2 4 5



as output. No column header is needed and eventually I will store that in list.










share|improve this question



















  • 1




    df.iloc[1].values
    – Alex
    23 hours ago











  • I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
    – jezrael
    23 hours ago











  • Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
    – jezrael
    23 hours ago











  • I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
    – Sayantan
    23 hours ago










  • hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
    – jezrael
    23 hours ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











e.g -



df= A B C
1 2 3
2 4 5
2 1 3


I want to access second row without header



If I do df.iloc[[1]] it is giving me -



 A B C
2 4 5


as output, but I want



2 4 5



as output. No column header is needed and eventually I will store that in list.










share|improve this question















e.g -



df= A B C
1 2 3
2 4 5
2 1 3


I want to access second row without header



If I do df.iloc[[1]] it is giving me -



 A B C
2 4 5


as output, but I want



2 4 5



as output. No column header is needed and eventually I will store that in list.







python pandas dataframe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 21 hours ago









halfer

14.1k757104




14.1k757104










asked 23 hours ago









Sayantan

243




243







  • 1




    df.iloc[1].values
    – Alex
    23 hours ago











  • I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
    – jezrael
    23 hours ago











  • Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
    – jezrael
    23 hours ago











  • I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
    – Sayantan
    23 hours ago










  • hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
    – jezrael
    23 hours ago












  • 1




    df.iloc[1].values
    – Alex
    23 hours ago











  • I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
    – jezrael
    23 hours ago











  • Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
    – jezrael
    23 hours ago











  • I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
    – Sayantan
    23 hours ago










  • hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
    – jezrael
    23 hours ago







1




1




df.iloc[1].values
– Alex
23 hours ago





df.iloc[1].values
– Alex
23 hours ago













I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
– jezrael
23 hours ago





I will store that in list. - Do you think values 2, 4 ,5 ? Like df.iloc[1].tolist() ?
– jezrael
23 hours ago













Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
– jezrael
23 hours ago





Or is necessary save DataFrame with no header to csv like df.iloc[[1]].to_csv(file, header=None, index=False) ?
– jezrael
23 hours ago













I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
– Sayantan
23 hours ago




I will take 2,4,5 and eventually store in a list..which will be looked like ['2','4','5']
– Sayantan
23 hours ago












hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
– jezrael
23 hours ago




hmmm, so need join it by space like ' '.join(df.iloc[1].tolist()) ?
– jezrael
23 hours ago












2 Answers
2






active

oldest

votes

















up vote
0
down vote













use list_ob = list(df.iloc[1]) and use list_ob, it will return desired output.






share|improve this answer



























    up vote
    0
    down vote













    try this below snippets to get different types of results as you wish,



    print df.iloc[1].values #<type 'numpy.ndarray'> [2 4 5]
    print df.iloc[1].values.tolist() #<type 'list'> [2, 4, 5]
    print ' '.join(map(str,df.iloc[1].values.tolist())) #<type 'str'> 2 4 5





    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220899%2fhow-to-access-a-row-from-a-panda-dataframe-using-index-without-column-header%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      use list_ob = list(df.iloc[1]) and use list_ob, it will return desired output.






      share|improve this answer
























        up vote
        0
        down vote













        use list_ob = list(df.iloc[1]) and use list_ob, it will return desired output.






        share|improve this answer






















          up vote
          0
          down vote










          up vote
          0
          down vote









          use list_ob = list(df.iloc[1]) and use list_ob, it will return desired output.






          share|improve this answer












          use list_ob = list(df.iloc[1]) and use list_ob, it will return desired output.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 23 hours ago









          Nikhil Mangire

          629




          629






















              up vote
              0
              down vote













              try this below snippets to get different types of results as you wish,



              print df.iloc[1].values #<type 'numpy.ndarray'> [2 4 5]
              print df.iloc[1].values.tolist() #<type 'list'> [2, 4, 5]
              print ' '.join(map(str,df.iloc[1].values.tolist())) #<type 'str'> 2 4 5





              share|improve this answer
























                up vote
                0
                down vote













                try this below snippets to get different types of results as you wish,



                print df.iloc[1].values #<type 'numpy.ndarray'> [2 4 5]
                print df.iloc[1].values.tolist() #<type 'list'> [2, 4, 5]
                print ' '.join(map(str,df.iloc[1].values.tolist())) #<type 'str'> 2 4 5





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  try this below snippets to get different types of results as you wish,



                  print df.iloc[1].values #<type 'numpy.ndarray'> [2 4 5]
                  print df.iloc[1].values.tolist() #<type 'list'> [2, 4, 5]
                  print ' '.join(map(str,df.iloc[1].values.tolist())) #<type 'str'> 2 4 5





                  share|improve this answer












                  try this below snippets to get different types of results as you wish,



                  print df.iloc[1].values #<type 'numpy.ndarray'> [2 4 5]
                  print df.iloc[1].values.tolist() #<type 'list'> [2, 4, 5]
                  print ' '.join(map(str,df.iloc[1].values.tolist())) #<type 'str'> 2 4 5






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 21 hours ago









                  Mohamed Thasin ah

                  2,94331234




                  2,94331234



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220899%2fhow-to-access-a-row-from-a-panda-dataframe-using-index-without-column-header%23new-answer', 'question_page');

                      );

                      Post as a guest














































































                      這個網誌中的熱門文章

                      How to combine Bézier curves to a surface?

                      Mutual Information Always Non-negative

                      Why am i infinitely getting the same tweet with the Twitter Search API?