# Question for PrettyTables.jl users: Can we remove filters?

**URL:** https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609
**Category:** Community
**Tags:** prettytables
**Created:** [June 11, 2022, 10:06pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609 "2022-06-11T22:06:35Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 11, 2022, 10:06pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/1 "2022-06-11T22:06:35Z")

</div>

Hi everyone!

I am building a new version of PrettyTables.jl with the features necessary to replace the LaTeX and HTML backend in DataFrames.jl. However, I am facing some problems.

Most of them is related to a feature in PrettyTables: the filters! Currently, you can pass a set of functions to filter the rows or columns that will be printed. I did this to filter some satellite telemetries that could indicate some problem back in the day. However, since DataFrames now uses PrettyTables to print tables to stdout, we can just use all the powerful mechanisms in DataFrame to perform the filtering.

So, I have the following question: Are anyone actively using the filters in PrettyTables? I am really considering removing them in the next release. It will make adding new features much easier.

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [June 11, 2022, 10:41pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/2 "2022-06-11T22:41:58Z")

</div>

I am not using the filters in PrettyTables. If a need to filter arise, I would prefer to use DataFrame operations. Making life simpler for the package maintainer is +1.

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [June 11, 2022, 11:01pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/3 "2022-06-11T23:01:22Z")

</div>

+1 from me too! Composing functionality (e.g. filter then print) provides a simpler and more flexible interface than overburdening a function with too much responsibility.

---

<div class="post-metadata">

### Author: ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)
#### Post date: [June 12, 2022, 1:11am UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/4 "2022-06-12T01:11:36Z")

</div>

I actually do use filters for when I have data that is not in dataframes.  
I am in favor of removing filters from PrettyTables, but would you share a proposed workflow @Ronis_BR that does not use filtering within PrettyTables?  
Thanks!

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [June 12, 2022, 5:56am UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/5 "2022-06-12T05:56:07Z")

</div>

Speaking as a PrettyTables user who basically never encounters DataFrames, I’m also all for removing those filters. It’s trivial and more convenient to filter a table beforehand anyway, thanks to Julia `map()` and `filter()` functions that work with many table types.  
How is this decision related to DataFrames at all?

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [June 12, 2022, 9:27am UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/6 "2022-06-12T09:27:27Z")

</div>

PrettyTables consumes more data types than its filters can handle, as they seem to apply only to matrix data?

Filtering is best done outside the package, but I wouldn’t say it’s trivial. Examples would be welcome, even if they would be outside the scope of the package.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 12, 2022, 1:49pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/7 "2022-06-12T13:49:26Z")

</div>

Hi everyone!

Thanks for the comments! 🙂

It seems we can remove the filters. It should be easy to provide examples that can perform the same filtering outside PrettyTables. The only problem is that PrettyTables does not duplicate data to print the filtered content. Without it, you will have to filter the table before, creating another one, that will be printed.

Maybe this feature can belong to a new package, that does the filtering without copying.

> How is this decision related to DataFrames at all?

It is just because since DataFrames now uses PrettyTables, you can use it to filter data if required, but should be overkill in most of cases if you are not using DataFrames.

> PrettyTables consumes more data types than its filters can handle, as they seem to apply only to matrix data?

Yes, this is true.

> I am in favor of removing filters from PrettyTables, but would you share a proposed workflow @Ronis_BR that does not use filtering within PrettyTables?

Ok! I will think about it.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [June 12, 2022, 2:08pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/8 "2022-06-12T14:08:33Z")

</div>

I’ve never used the filters. So its fine by me!

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 12, 2022, 2:31pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/9 "2022-06-12T14:31:39Z")

</div>

Thanks! I am starting to realize that it is one of those features that are used only in a very specific moments. I could let it there, no problem! However, it is also one of those features that makes almost everything very difficult.

For example, I need to print in HTML how many rows are hidden in case the user wants to render only a part of it. However, if it has a filter, I need to filter the entire table to check how many rows would be actually displayed… This is just one example.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 12, 2022, 2:57pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/10 "2022-06-12T14:57:35Z")

</div>

And it is done 🙂

[https://github.com/ronisbr/PrettyTables.jl/commit/51e5225ad4cfb3bcb3db01e0ba8ad4f13fd49d3b](https://github.com/ronisbr/PrettyTables.jl/commit/51e5225ad4cfb3bcb3db01e0ba8ad4f13fd49d3b)

Thanks everyone for the discussion!

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [June 12, 2022, 4:43pm UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/11 "2022-06-12T16:43:07Z")

</div>

Regarding tables that are not `DataFrame`s, I wanted to mention the [TableOperations](https://github.com/JuliaData/TableOperations.jl) package, which has `filter` and `select` methods for arbitrary tables. I haven’t checked the details, but I imagine those should cover most of the filtering functionality in PrettyTables.

---

<div class="post-metadata">

### Author: ![merlin](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@merlin](https://discourse.julialang.org/u/merlin)
#### Post date: [June 15, 2022, 4:31am UTC](https://discourse.julialang.org/t/question-for-prettytables-jl-users-can-we-remove-filters/82609/12 "2022-06-15T04:31:56Z")

</div>

This is good. I had been using the filters at times, because it was there. I think filtering ahead of the PrettyTable process makes more sense, and now you have taken away an option that I needed to think about.
