I’m reading data from Excel and I want to format numbers как в Excel but I get this small error

Solution for I’m reading data from Excel and I want to format numbers как в Excel but I get this small error
is Given Below:

de_f = excel_data_df['reaction_time'].unique()
print(de_f)

[2.9690e+03 5.1910e+03 4.2020e+03 4.8900e+02 4.7160e+03        nan
 5.0050e+03 3.1000e+01 5.1580e+03 4.7260e+03 1.7900e+02 5.0000e+01
 3.4000e+01 3.7000e+01 4.5990e+03 2.6000e+01 4.2540e+03 4.7000e+01
 1.4000e+01 1.2140e+03 2.0000e+01 2.3700e+02 8.0000e+01 1.2000e+01
 3.2040e+03 3.3540e+03 1.3200e+02 1.0000e+01 8.0000e+00 1.1000e+01]

I can’t understand how to do formatting like in Excel for the first time I’m working with this library, someone tell me how it’s done, I’ve searched a lot of forums , but I didn’t find anything worthwhile

de_f.to_excel('/content/name.xlsx')

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-95-d5b2653bd3fa> in <module>()
----> 1 de_f.to_excel('/content/name.xlsx')

AttributeError: 'numpy.ndarray' object has no attribute 'to_excel'

Your problem is that after doing unique function you get a numpy ndarray which of course doesn’t have the to_excel function.

You should convert the numpy ndarray to a DataFrame first.

You can follow this example code to resolve your issue:

import pandas as pd
df = pd.DataFrame({"reaction_time":[1000,2000,3000,1500,2500,2500,2000,3000]})
l = df["reaction_time"].unique()
out = pd.DataFrame(l)
out.columns=["reaction_time"]
out.to_excel(r"D:test.xls")

Then the excel file would have following data:

enter image description here