0

i have sliced data from my excel file below, and it giving me an output: now i want to convert this output into an array or a list how can i do it?

df = pd.read_excel(r'C:\Users\Hp\Desktop\office work.xlsx',sheet_name=1)
df.iloc[0:1,10:17]

output:

P00 P01 P02 P03 P04 P05
0   5.630278    1.372496    0.055846    0.290576    -0.080946   2.540781
mozway
  • 194,879
  • 13
  • 39
  • 75
  • 2
    `df.to_numpy()` or `df.to_list()`? – mozway Apr 13 '22 at 12:12
  • Does this answer your question? [Pandas DataFrame column to list](https://stackoverflow.com/questions/23748995/pandas-dataframe-column-to-list) – Freddy Mcloughlan Apr 13 '22 at 12:15
  • unfortunately it is giving me an error... 'DataFrame' object has no attribute 'to_list' – osama afzal Apr 13 '22 at 12:30
  • What do you want to do exactly ? Why are you slicing on a range if you want a single index ? Try `df.iloc[0, 10:17].to_list()`, since slicing on a single index returns a `Series` instead of a dataframe, this should do the trick – user12932966 Apr 13 '22 at 12:34

0 Answers0