0

Now, I need to select some data from excel file and draw a chart using Python.

The first problem I come across is removing the first column in Excel which contains some useless texts. My code is down below:

import  pandas as pd
df = pd.read_excel ('Kopie von Grafik_Pfahlsymposium.xlsx')
x = df.iloc[1:45, 12:13] # i need the 13th colomn and 1st-45th rows as the x value for my chart
print (x)

and the result in python, what I need is only the second column which contains the important data:

Unnamed: 12
Alpha Ventus - AV 4      23.6885
Alpha Ventus - AV 5      15.7377
Alpha Ventus - AV11      17.3387
Amrumbank-OSS            15.9967
Borkum West 2 - BW2      7.90323
Borkum West 2 - BW4      7.94355
Borkum West 2 - BW12     10.0806
Borkum West 2 - BW15     12.9032
Borkum West 2 - BW31     10.0806
Borkum West 2 - BW34     11.2903
Borkum West 2 - BW36     9.55645
Borkum West 2 - BW41     13.3065
Borkum West 2 - BW44     10.8871
BorWin alpha             28.4339
BorWin beta                   20
BorWin gamma             21.9992
Butendiek OSS            19.6883
Dan Tysk OAP             24.1331
Dan Tysk OSS             27.3523
DolWin alpha             20.5086
DolWin gamma - B1          22.92
DolWin gamma - B2           23.6
DolWin gamma - B3           24.8
Global Tech - GT 12      11.6935
Global Tech - GT 17      12.0968
Global Tech - GT 38      14.5161
Global Tech - GT 45      12.0968
Global Tech - GT 60      14.5161
Global Tech - GT 72      21.7742
HelWin alpha - AC1         32.65
HelWin alpha - BC1            33
HelWin alpha - BC2            33
HelWin beta - No3        28.0558
HelWin beta - No6        28.0968
SylWin alpha - A1          27.44
SylWin alpha - A2         22.624
SylWin alpha - A3         27.328
SylWin alpha - B1           27.4
SylWin alpha - C1         27.368
SylWin alpha - C3         27.332
Veja Mate - VM 60        4.73077
Veja Mate - VM 61        4.52564
Veja Mate - VM 62        4.38333
Veja Mate - VM 63        4.33333

Some datas from the excel file: Some datas from the excel file:

1

2 Answers 2

2

df.to_excel(export_filename, index=False, engine='xlsxwriter')

Sign up to request clarification or add additional context in comments.

Comments

1

Try the using drop().

df = df.drop(0, axis=1)
# This should remove the first column

Unless you want edit the actual excel file, in which case you could just write from pandas (as of now, you've just read the file; writing would edit/replace contents in it)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.