Excel has a list of numbers, I am expecting to see something like this:
[110652450, 5309154]
However I see something like this:
[[110652450], [5309154]]
I tried newtest = [x[:-1] for x in df]
suggested on a similar question but that just removes my numbers and keeps the braquets
df = pd.read_excel(filename.xlsx",sheetname='Sheet1')
df = df.values.tolist()
print(df)
I didn't quite get your question, but you seem to be looking for something like this?
df = [[110652450], [5309154]]
newest = [i[0] for i in df]
print(newest)
>> [110652450,5309154]
numpy.squeeze might be the preferred method to do this. Call np.squeeze(a)
for the array that you wish to flatten. np.squeeze should be much faster than a list comprehension such as [e[0] for e in a]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With