Q:

slice and fill rows/columns pandas

I have a small sample data
import pandas as pd
d = {
 'title': ['string1', 'string2', 'string3', 'string4', 'string5', 'string6'],
 'Num/Den': ['Numerator', 'Denominator', 'Numerator', 'Denominator', 'Numerator','Denominator', 
             'Numerator','Denominator','Numerator', 'Denominator', 'Numerator', 'Denominator'],
 'two': ['tstring1', 'tstring2', 'tstring3', 'tstring4', 'tstring5', 'tstring6', 
         'tstring7', 'tstring8','tstring9','tstring10','tstring11','tstring12']

}
df = pd.DataFrame(d)

This code will not work because the columns do not have the same rows! I am not sure how to show the raw data in another way on stackoverflow. 
the data looks like this:
title         Num/Den             two
string1       Numerator          tstring1
              Denominator        tstring2
string2       Numerator          tstring3
              Denominator        tstring4
string3       Numerator          tstring5
              Denominator        tstring6    
string4       Numerator          tstring7
              Denominator        tstring8    
string5       Numerator          tstring9
              Denominator        tstring10
string6       Numerator          tstring11
              Denominator        tstring12 

I want my data to look like this, basically just fill out the empty cell with the value of its previous cell:
title         Num/Den             two
string1       Numerator          tstring1
string1       Denominator        tstring2
string2       Numerator          tstring3
string2       Denominator        tstring4
string3       Numerator          tstring5
string3       Denominator        tstring6    
string4       Numerator          tstring7
string4       Denominator        tstring8    
string5       Numerator          tstring9
string5       Denominator        tstring10
string6       Numerator          tstring11
string6       Denominator        tstring12 

A:

You can replace empty string with nan/None, and then do a ffill:
df['title'] = df.title.replace("", pd.np.nan).ffill()
df

#       Num/Den   title     two
#0  Numerator   string1 tstring1
#1  Denominator string1 tstring2
#2  Numerator   string2 tstring3
#3  Denominator string2 tstring4
# ...

