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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:07:13+00:00 2026-06-17T09:07:13+00:00

I have a pandas time series data frame. df date is the index. Three

  • 0

I have a pandas time series data frame. df

date is the index. Three columns, cusip, ticker, factor.

I want to decile the data per date. About 100 factors per date…Each date will be deciled 1 to 10.

As a first attempt, I tried to decile the whole data frame regardless of date. I used:

factor = pd.cut(df.factor, 10)  #This gave an error:

adj = (mx - mn) * 0.001 # 0.1% of the range

Sybase.Error: (‘Layer: 2, Origin: 4\ncs_calc: cslib user api layer: common library error: The conversion/operation resulted in overflow.’)

The dataframe has 1mm rows. Is it a size issue? An nan issue?

Three questions.

  1. What is wrong with the current function?
  2. How do I get the count of number of nan’s in a column?
  3. Any recommendations on deciling per date?

Thank you for the help. New to pandas python.

SAMPLE DATA:

df:             cusip      ticker    factor
date
2012-01-05       XXXXX       ABC       4.26
2012-01-05       YYYYY       BCD       -1.25
...(100 more stocks on this date)  
2012-01-06       XXXXX       ABC       3.25
2012-01-06       YYYYY       BCD       -1.55
...(100 more stocks on this date)

OUTPUT for what I would like:

#column with the deciles, lined up with the df.
decile
10
2
...
10
3
...

I can then append this to my dataframe to have a new column. Each date is deciled and each data point then has their corresponding decile on that date. Thanks.

Stack Trace:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/core/groupby.py", line 1817, in transform res = wrapper(group)

File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/core/groupby.py", line 1807, in <lambda> wrapper = lambda x: func(x, *args, **kwargs) File "<stdin>", line 1, in <lambda> File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/tools/tile.py", line 138, in qcut bins = algos.quantile(x, quantiles)

File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/core/algorithms.py", line 272, in quantile return algos.arrmap_float64(q, _get_score) File "generated.pyx", line 1841, in pandas.algos.arrmap_float64 (pandas/algos.c:71156) File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/core/algorithms.py", line 257, in _get_score idx % 1)

File "/misc/apps/linux/python-2.6.1/lib/python2.6/site-packages/pandas-0.10.0-py2.6-l‌​inux-x86_64.egg/pandas/core/algorithms.py", line 279, in _interpolate return a + (b - a) * fraction File "build/bdist.linux-x86_64/egg/Sybase.py", line 246, in _cslib_cb Sybase.Error: ('Layer: 2, Origin: 4\ncs_calc: cslib user api layer: common library error: The conversion/operation resulted in overflow.', <ClientMsgType object at 0x1c4da730>)
  • 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-17T09:07:13+00:00Added an answer on June 17, 2026 at 9:07 am

    Toy example. First make a datetime index. Here I make an index using two days repeated 10 times each. I then make some dummy data using randn.

    In [1]: date_index = [datetime(2012,01,01)] * 10 + [datetime(2013,01,01)] * 10
    
    In [2]: df = DataFrame({'A':randn(20),'B':randn(20)}, index=date_index)
    
    In [3]: df
    Out[3]:
                       A         B
    2012-01-01 -1.155124  1.018059
    2012-01-01 -0.312090 -1.083568
    2012-01-01  0.688247 -1.296995
    2012-01-01 -0.205218  0.837194
    2012-01-01  0.700611 -0.001015
    2012-01-01  1.996796 -0.914564
    2012-01-01 -2.268237  0.517232
    2012-01-01 -0.170778 -0.143245
    2012-01-01 -0.826039  0.581035
    2012-01-01 -0.351097 -0.013259
    2013-01-01 -0.767911 -0.009232
    2013-01-01 -0.322831 -1.384785
    2013-01-01  0.300160  0.334018
    2013-01-01 -1.406878 -2.275123
    2013-01-01  1.722454  0.873262
    2013-01-01  0.635711 -1.763352
    2013-01-01 -0.816891 -0.451424
    2013-01-01 -0.808629 -0.092290
    2013-01-01  0.386046 -1.297096
    2013-01-01  0.261837  0.562373
    

    If I understand your question correctly, you want to decile within each date. To do that, you can first move the index into the dataframe as a column. Then, you can groupby by the new column (here it’s called index), and use transform with a lambda function. The lambda function below, applies pandas.qcut to the grouped series and returns the labels attribute.

    In [4]: df.reset_index().groupby('index').transform(lambda x: qcut(x,10).labels)
    Out[4]:
        A  B
    0   1  9
    1   4  1
    2   7  0
    3   5  8
    4   8  5
    5   9  2
    6   0  6
    7   6  3
    8   2  7
    9   3  4
    10  3  6
    11  4  2
    12  6  7
    13  0  0
    14  9  9
    15  8  1
    16  1  4
    17  2  5
    18  7  3
    19  5  8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pandas.Series of time-stamped data - basically a sequence of events: 0
I have a Pandas Data Frame object that has 1000 rows and 10 columns.
I have a pandas DataFrame with a date column. It is not an index.
I have an intraday 30-second interval time series data in a CSV file with
I have an irregularly indexed time series of data with seconds resolution like: import
I have a csv file where one of the columns is a date/time string.
I have a pandas dataframe consisting of 23 series with a default sequential index
I have a pandas dataframe like: In [61]: df = DataFrame(np.random.rand(3,4), index=['art','mcf','mesa'], columns=['pol1','pol2','pol3','pol4']) In
I have a DataFrame that consists of many stacked time series. The index is
I have a pandas DataFrame that has multiple columns in it: Index: 239897 entries,

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.