Questions tagged [datetimeindex]

Immutable ndarray of datetime64 data, represented internally as int64

Immutable ndarray of datetime64 data, represented internally as int64, and which can be boxed to Timestamp objects that are subclasses of datetime and carry metadata such as frequency information.

325 questions
0
votes
1 answer

Joining Dataframes on DatetimeIndex by Seconds and Minutes for NaNs

I'm looking for a good way to align dataframes each having a timestamp that "includes" seconds without loosing data. Specifically, my problem looks as follows: Here d1 is my "main" dataframe. ind1 = pd.date_range("20120101",…
Tim
  • 125
  • 3
  • 12
0
votes
1 answer

convert pandas timedelta output from days to quarter

here is my input: import pandas as pd dt_one = pd.to_datetime('2015/5/25') - pd.tseries.offsets.QuarterEnd() dt_two = pd.to_datetime('2016/9/15') - pd.tseries.offsets.QuarterEnd() here is my output: (dt_two - dt_one) Out[75]: Timedelta('457 days…
Siraj S.
  • 3,481
  • 3
  • 34
  • 48
0
votes
0 answers

DateTimeIndex resample to create empty rows

companies = users_file2.set_index('Created').Clean_Company2 companies = companies.groupby(pd.TimeGrouper(freq='W')).unique() weekly = companies[:].apply(pd.Series).stack().drop_duplicates() weekly = weekly.groupby(level=0).apply(lambda x:…
Frederic Bastiat
  • 695
  • 4
  • 12
  • 31
0
votes
1 answer

Pandas DatetimeIndex in Multi Index shift

I have some Pandas (python) data frames that are created by collecting data roughly every 8 milliseconds. The data is broken down into blocks, where a sequence restarts. All the blocks have a label, and there is a timestamp column indicating the…
Andrew Schoen
  • 145
  • 1
  • 11
-1
votes
1 answer

How to use DatetimeIndex as an index in Pandas

I have a dataframe called region and the an array y is DatetimeIndex type like that: print(y) DatetimeIndex(['2016-01-01 00:30:00', '2016-01-01 01:30:00', '2016-01-01 02:00:00', '2016-01-01 03:00:00']) But the problem, I do not know…
Hamzah
  • 8,175
  • 3
  • 19
  • 43
-1
votes
1 answer

How to optimize the conversion of DateTimeIndex to a certain column of a DataFrame in a specific format?

I have a DateTimeIndex, I need to convert to a certain column of the Dataframe, and use a specific format, my code is as follows, how to optimize? import numpy as np import pandas as pd original = pd.date_range(start='20210520 09:00:00',…
jaried
  • 632
  • 4
  • 15
-1
votes
1 answer

TypeError: How to fix Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'

I want to compute Compound monthly stock returns over 12 months to obtain annual returns. Here is what I have done, but I am getting an error massage Month_Return = pd.read_csv("Monthly Stock Return.csv") Month_Return.set_index('gvkey',…
chuky pedro
  • 756
  • 1
  • 8
  • 26
-1
votes
2 answers

pandas conditionally assign values to new column based on value of a datetimeindex

I am trying to use a the datetimeindex of a pandas dataframe to assign a new column called 'season'. winter =[12,1,2] spring =[3,4,5] summer =[6,7,8] autumn =[9,10,11] DTX_index = [datetime(2017, 2, 1).date(), datetime(2017, 3, 1).date(),…
user3062260
  • 1,584
  • 4
  • 25
  • 53
-1
votes
2 answers

Bar Plot with recent dates left where date is datetime index

I tried to sort the dataframe by datetime index and then plot the graph but no change still it was showing where latest dates like 2017, 2018 were in right and 2008, 2009 were left. I wanted the latest year to come left and old to the right. This…
-1
votes
1 answer

matplotlib - plot a serial with datetimeindex ;TypeError: Cannot compare type 'Timestamp' with type 'float'

this is the code: def showbug_TemBiased(dt): ax1 = plt.subplot(1,1,1) legendlist=[] for i in range(4): power='CH{}power(KW)'.format(i+1) tem=[col for col in dt.columns if col.find('CH{}'.format(i+1))!=-1 and…
L.ZH
  • 31
  • 3
1 2 3
21
22