Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9074659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:41:20+00:00 2026-06-16T18:41:20+00:00

I am having a real strange behaviour when trying to reindex a dataframe in

  • 0

I am having a real strange behaviour when trying to reindex a dataframe in pandas. My version of Pandas is 0.10.0 and I use Python 2.7.
Basically, when I load a dataframe:

eurusd = pd.DataFrame.load('EUR_USD_30Min.df').drop_duplicates().dropna()

eurusd

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 119710 entries, 2003-02-02 17:30:00 to 2012-12-28 17:00:00
Data columns:
open     119710  non-null values
high     119710  non-null values
low      119710  non-null values
close    119710  non-null values
dtypes: float64(4)

and then I try to reindex inside a larger date range:

newindex  = pd.DateRange(datetime.datetime(2002,1,1), datetime.datetime(2012,12,31), offset=pd.datetools.Minute(30))

newindex

<class 'pandas.tseries.index.DatetimeIndex'>
[2002-01-01 00:00:00, ..., 2012-12-31 00:00:00]
Length: 192817, Freq: 30T, Timezone: None

I get strange behaviour when trying to reindex the dataframe. If I reindex one larger part of the dataset I get this error:

eurusd[29558:29560].reindex(index=newindex)

Exception: Reindexing only valid with uniquely valued Index objects

But, if I do the same for two subsets of the data above, I don’t get the error:

Here’s the first subset, with no problems,

eurusd[29558:29559].reindex(index=newindex)

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 192817 entries, 2002-01-01 00:00:00 to 2012-12-31 00:00:00
Freq: 30T
Data columns:
open     1  non-null values
high     1  non-null values
low      1  non-null values
close    1  non-null values
dtypes: float64(4)

and here’s the second subset, still no problems,

eurusd[29559:29560].reindex(index=newindex)

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 192817 entries, 2002-01-01 00:00:00 to 2012-12-31 00:00:00
Freq: 30T
Data columns:
open     1  non-null values
high     1  non-null values
low      1  non-null values
close    1  non-null values
dtypes: float64(4)

I am really going crazy about this, and cannot understand the reasons of this. It seems like the dataframe is ‘clean’ from duplicates, and duplicated indexes…. I can provide the pickle file for the dataframe if you want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:41:21+00:00Added an answer on June 16, 2026 at 6:41 pm

    You could groupby the index and take the first entry (see docs):

    df.groupby(level=0).first()
    

    Example:

    In [1]: df = pd.DataFrame([[1], [2]], index=[1, 1])
    
    In [2]: df
    Out[2]: 
       0
    1  1
    1  2
    
    In [3]: df.groupby(level=0).first()
    Out[3]: 
       0
    1  1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having real trouble trying to use the .bz2 stuff from the SharpZipLib library
I'm having real trouble getting python to use a custom dns server. I have
I'm having real problems getting PDO_MYSQL working. I started by just trying to install
I've been having real problems trying to get a ruby script to run through
I am having real problems trying debug my code to malfunctioning print statements. I
I have a Google spreadsheet and I am having real difficulty trying to work
I'm having a real strange problem using GCC for ARM with the optimizations turned
Strange way to put a question, anyway ... Basically this is my first real
I'm trying to run a stored procedure and having real issues debugging. I've tried
I am having real trouble trying to deserialize some XML and was hoping someone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.