Ask Your Question

A problem with Pandas dataframe (Need help urgently)

asked 2020-06-17 04:28:08 -0600

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')

I can have the head simply


The the column names

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

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


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


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

tmonteil gravatar imagetmonteil ( 2020-06-17 04:55:02 -0600 )edit

Do you mean something like cr.iloc[9:29]? Read the doc :

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

1 answer

Sort by » oldest newest most voted

answered 2020-06-17 15:35:29 -0600

Sébastien gravatar image

updated 2020-06-17 15:36:28 -0600

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:


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


Asked: 2020-06-17 04:28:08 -0600

Seen: 55 times

Last updated: Jun 17