4

I have this list:

import pandas as pd
l = [[1,2,3],[4,5,6],[7,8,9]]
New_dataframe = pd.DataFrame(l)
print(New_dataframe)

Output:

   0  1  2
0  1  2  3
1  4  5  6
2  7  8  9

I want to remove those indexed rows and columns. How to achieve that??DataFrame I would like to see is this:

1  2  3
4  5  6
7  8  9

How to remove that index column and rows??

4
  • New_dataframe.values Commented May 12, 2018 at 5:56
  • can you elaborate more? @liliscent Commented May 12, 2018 at 5:57
  • @ShubhamKuse - What is reason for it? Commented May 12, 2018 at 6:04
  • I have responded to your thread @jezrael Commented May 12, 2018 at 6:06

1 Answer 1

4

If want see only values is possible convert to 2d numpy array:

print (New_dataframe.values)
[[1 2 3]
 [4 5 6]
 [7 8 9]]

If need see DataFrame it is possible by:

print (New_dataframe.to_csv(index=False, header=None, sep=' '))
1 2 3
4 5 6
7 8 9

print (New_dataframe.to_string(index=False, header=None))
1  2  3
4  5  6
7  8  9

EDIT:

For convert to excel without index and headers use parameter index=False and header=None:

New_dataframe.to_excel('test.xlsx', index=False, header=None)
Sign up to request clarification or add additional context in comments.

1 Comment

okay so i want to convert it into excel file without the index columns and rows?can you guide me on that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.