Ask Your Question
0

A problem with Pandas dataframe (Need help urgently)

asked 2020-06-17 11:28:08 +0100

Cyrille gravatar image

I have a huge Excel data basis. I want to use Pandas to read and manipulate it

This works

import pandas as pd
xlsx = pd.ExcelFile(r'c:\vinsdeloire\Chinonrougegpsga1.xlsx')
cr1=pd.read_excel(xlsx,sheet_name='Données indiv campagne')# sheet_name= est facultatif
cr2=pd.read_excel(xlsx,sheet_name='Données indiv année civile')
cr3=pd.read_excel(xlsx,sheet_name='pilotage GPS')
cr1

I can have the head simply

cr1.head()

The the column names

for idx,column in enumerate(cr1.columns):
    print(idx,column)

I can use the name of one column

cr1['Rotation stock en nb de mois campagne 2019-2020']

But what I do not understand is that until now a command like this one doesn't work

cr11=cr1.iloc[:-9,29]
cr11

given this error

Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types

I make certainly a mistake and I cannot give more than my code but I do not see my error. And unfrotunately its very urgent. I will remove this later.

Thanks by advance

edit retag flag offensive close merge delete

Comments

Could you please make the file Chinonrougegpsga1.xlsx accessible somewhere ?

tmonteil gravatar imagetmonteil ( 2020-06-17 11:55:02 +0100 )edit

Do you mean something like cr.iloc[9:29]? Read the doc : https://pandas.pydata.org/pandas-docs...

FrédéricC gravatar imageFrédéricC ( 2020-06-17 13:04:25 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-06-17 22:35:29 +0100

Sébastien gravatar image

updated 2020-06-17 22:36:28 +0100

I think it is because pandas does not like Sage integers, instead use raw integers which prevent them to be preparsed and turned into Sage integers:

cr11=cr1.iloc[:-9r,29r]

Similar problem exists (or existed) with other python libraries as numpy, sympy, PIL, etc. The bug was fixed for some, but not with pandas.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-17 11:28:08 +0100

Seen: 709 times

Last updated: Jun 17 '20