Question: I received a lot of help previously, but I just ran into another issue, and was wondering if anyone would have any insight.

In a [previous post](https://stackoverflow.com/questions/17666980/comparing-subsequent-rows-and-finding-overlapping-time-intervals), I wrote that I have a dataset (it actually has about 50 rows), let’s call it “Times”:

```
> Times <- read.csv(“Times.csv”, stringsAsFactors=FALSE, header=TRUE)
> Times

Num     Start          End
1    00:09:41    00:25:025
2    00:11:21     00:41:32
3    00:34:39     00:58:01

```

Then, in order to find the overlapping time intervals, someone advised me to create a band matrix – comparing all of the rows.

```
Overlap <- outer (Times$Start, Times$End, function (x,y) y > x)
Overlap [upper.tri (Overlap) | col (Overlap) = = row(Overlap)] <- NA
Overlap

       [,1]   [,2]   [,3]           
[1,]     NA     NA     NA
[2,]   TRUE     NA     NA
[3,]  FALSE   TRUE     NA

```

So at this point, I know which rows overlap, but ideally I would like to have an output that resembles my original dataframe, but excluding those rows that don’t overlap any other rows.

Is there any way to omit rows that contain no TRUEs? And is it possible to convert this back to a dataframe?

Thank you for any help you can offer!

Answer: 
If you're just trying to print that:

```
for k, v in dct.iteritems():
    print repr(k)+ ":(" + ", ".join("Country{}:{}".format(i,c) for i,c in enumerate(v, start=1)) + ")"

```

Output:

```
'Europe':(Country1:Germany, Country2:France, Country3:Italy)
'Asia':(Country1:India, Country2:China, Country3:Malaysia)

```

Note: I'm abusing the function of `repr()` to get the quotes in there. You could just as well do `"'" + str(k) + "'"`.

The reason why your code doesn't work is your use of `:` outside of a dictionary initialization or comprehension. That is, you can do `d = {'a':'b'}` but you can't do `print 'a':'b'`. Also, you shouldn't use `dict` as a variable name, because it is a keyword.

My solution will work for tuples which have more (or even less) than 3 elements in them, too.
There's nothing built-in that I know of that will do it, but it's pretty simple to do what you want:

```
countries = {
    'Europe': ('Germany', 'France', 'Italy'),
    'Asia': ('India', 'China', 'Malaysia'),
}

for k, v in countries.iteritems():
    print k+':', tuple(map(lambda c: 'Country%d:%s' % c, enumerate(v, start=1)))

```

Output:

```none
Europe: ('Country1:Germany', 'Country2:France', 'Country3:Italy')
Asia: ('Country1:India', 'Country2:China', 'Country3:Malaysia')

```