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 9125887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:54:34+00:00 2026-06-17T06:54:34+00:00

I have an intraday 30-second interval time series data in a CSV file with

  • 0

I have an intraday 30-second interval time series data in a CSV file with the following format:

20120105, 080000,   1
20120105, 080030,   2
20120105, 080100,   3
20120105, 080130,   4
20120105, 080200,   5

How can I read it into a pandas data frame with these two different indexing schemes:

1, Combine date and time into a single datetime index

2, Use date as the primary index and time as the secondary index in a multiindex dataframe

What are the pros and cons of these two schemes? Is one generally more preferable than the other? In my case, I would like to look at time-of-the-day analysis but am not entirely sure which scheme will be more convenient for my purpose. Thanks in advance.

  • 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-17T06:54:35+00:00Added an answer on June 17, 2026 at 6:54 am
    1. Combine date and time into a single datetime index

      df = pd.read_csv(io.BytesIO(text), parse_dates = [[0,1]], header = None, index_col = 0)
      print(df)
      #                      2
      # 0_1                   
      # 2012-01-05 08:00:00  1
      # 2012-01-05 08:00:30  2
      # 2012-01-05 08:01:00  3
      # 2012-01-05 08:01:30  4
      # 2012-01-05 08:02:00  5
      
    2. Use date as the primary index and time as the secondary index in a
      multiindex dataframe

      df2 = pd.read_csv(io.BytesIO(text), parse_dates = True, header = None, index_col = [0,1])
      print(df2)
      #                   2
      # 0          1       
      # 2012-01-05 80000  1
      #            80030  2
      #            80100  3
      #            80130  4
      #            80200  5
      

    My naive inclination would be to prefer a single index over the multiindex.

    • As the Zen of Python asserts, “Flat is better than nested”.
    • The datetime is one conceptual object. Treat it as such. (It is better to have one datetime object than multiple columns for the year, month, day, hour, minute, etc. Similarly, it is better to have one index rather than two.)

    However, I am not very experienced with Pandas, and there could be some advantage to having the multiindex when doing time-of-day analysis.

    I would try coding up some typical calculations both ways, and then see which one I liked better on the basis of ease of coding, readability, and performance.


    This was my setup to produce the results above.

    import io
    import pandas as pd
    
    text = '''\
    20120105, 080000,   1
    20120105, 080030,   2
    20120105, 080100,   3
    20120105, 080130,   4
    20120105, 080200,   5'''
    

    You can of course use

    pd.read_csv(filename, ...)
    

    instead of

    pd.read_csv(io.BytesIO(text), ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xts object (stock price time series) that is comprised of intraday
I currently have OHLC intraday data that I need to convert to 5min data.
I have an xts object that has intraday data: head(stocks[,1]) SMH.close 2009-01-02 09:31:00 17.66
Hi I have a intra day data table with the following columns : date,
have written this little class, which generates a UUID every time an object of
Is there a way to set the length of a data series using Google
Have the following cronjob set up in root's crontab: (centos 5.x) 2 * *
Have the following code: $(#blogs).mouseover( function () { $(this).addClass(hover); $(#home).removeClass(hover); $(#homepages).removeClass(hover); $(#apps).removeClass(hover); $(#facebook).removeClass(hover); $(#kontakt).removeClass(hover);
Have some runtime defined schedule for one week, for example: <schedule> <s day=Monday, time=1:00:00></s>
Have the following code: String s= v.request(engine/?key=, P4z72NmBa91&method=load); JSONParser parser = new JSONParser(); Object

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.