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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:10:04+00:00 2026-06-15T17:10:04+00:00

Objective: To create an Index that accommodates a pre-existing set of price data from

  • 0

Objective:

To create an Index that accommodates a pre-existing set of price data from a csv file. I can build an index using list comprehensions. If it’s done in that way, the construction would give me a filtered list of length 86,772–when run over 1/3/2007-8/30/2012 for 42 times (i.e. 10 minute intervals). However, my data of prices coming from the csv is length: 62,034. Observe that the difference in length is due to data cleaning issues.

That said, I am not sure how to overcome the apparent mismatch between the real data and this pre-built (list comp) dataframe.

Attempt:

Am I using the first two lines incorrectly?

data=pd.read_csv('___.csv', parse_dates={'datetime':[0,1]}).set_index('datetime')

dt_index = pd.DatetimeIndex([datetime.combine(i.date,i.time) for i in data.index])

ts = pd.Series(data.prices.values, dt_index)

Questions:

  1. As I understand it, I should use ‘combine’ since I want the index construction to be completely informed by my csv file. And, ‘combine’ returns a new datetime object whose date components are equal to the given date object’s, and whose time components are equal to the given time object’s.

  2. When I parse_dates, is it lumping the time and date together and considering it to be a ‘date’?

  3. Is there a better way to achieve the stated objective?

Traceback Error:

AttributeError: ‘unicode’ object has no attribute ‘date’

  • 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-15T17:10:05+00:00Added an answer on June 15, 2026 at 5:10 pm

    You can write this neatly as follows:

    ts = df1.prices
    

    Here’s an example:

    In [1]: df = pd.read_csv('prices.csv',
                      parse_dates={'datetime': [0,1]}).set_index('datetime')
    
    In [2]: df # dataframe
    Out[2]: 
                        prices  duty
    datetime                 
    2012-11-12 10:00:00      1     0
    2012-12-12 10:00:00      2     0
    2012-12-12 10:00:00      3     1
    
    
    In [3]: df.prices # timeseries
    Out[3]: 
    datetime
    2012-11-12 10:00:00    1
    2012-12-12 10:00:00    2
    2012-12-12 11:00:00    3
    Name: prices
    
    In [4]: ts = df.prices
    

    You can groupby date like so (similar to this example from the docs):

    In [5]: key = lambda x: x.date()
    
    In [6]: df.groupby(key).sum()
    Out[6]: 
                prices  duty
    2012-11-12       1     0
    2012-12-12       5     1
    
    In [7]: ts.groupby(key).sum()
    Out[7]: 
    2012-11-12    1
    2012-12-12    5
    

    Where prices.csv contains:

    date,time,prices,duty
    11/12/2012,10:00,1,0
    12/12/2012,10:00,2,0
    12/12/2012,11:00,3,1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My objective is to create navigation menu that has unlimited depth tree. I can
Someone on IRC told me I could create objective c objects directly from plist
The objective is to create indicators for a factor/string variable in a data frame.
My end objective is to create an applescript that intelligently inserts a bullet point
I need to create an Objective-C method that converts an int into a byte
I'm trying to create an objective C classe for my iPad application which can
Objective: I want to create a web service that allows me to connect to
Is there a way to create a True Type Font file programmatically in objective-c
My objective is create an apache module that will provide RESTful services (i.e., we
The objective is to create a custom route so that /undead will go to

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.