1

I have the following type of date in my data:

21.02.2015 08:00 - 21.02.2015 14:59 (CET) content1 content2

I now want to split the time into hourly time rows which contain the same contents as the row above (above I want it to be splitted until 14:00). How could I do this for the whole dataframe?

I would have started with converting like this:

def split_timerange(date1, date2):
    start= datetime.datetime.strptime(date1,'%Y.%m.%d %H:%M:S')
    end = datetime.datetime.strptime(date1, '%Y.%m.%d %H:%M:S')
    timerangehourly = pd.date_range(start,end,freq='H')

I do not know how to create for each element of the dataframe 'timerangehourly' a seperate column with the contents of the range. Any ideas? Thanks!

Additional info how the data looks like:

21.02.2015 08:00 - 21.02.2015 14:59 (CET)   Cancelled outage    Planned 
outage  Generation Unit     CTA|DE(50Hertz) PSW Markersbach PSS B   174 0

These are all the columns I have. What whould be perfect would be a transformation that in the first columns there is the time and it says which power station (e.g.'PSW Markersbach') has an outage. Is this somehow possible?

inneb
  • 1,060
  • 1
  • 9
  • 20
  • 2
    Can you add more data with desired output? Dates ranges are overlapping? Dates are in one day only? – jezrael Aug 12 '17 at 12:34
  • Do you already have the dataframe or you have a text which needs to be splitted? – Bharath M Shetty Aug 12 '17 at 12:44
  • I edited my question – inneb Aug 12 '17 at 13:16
  • Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. Thank you. – jezrael Aug 12 '17 at 13:58

0 Answers0