I want to build bookshelves in groups on pistons to maximize a smaller space. Do I need to make each bookshelf independent or, what are the most logical groupings for low, middle and high enchantments?
An enchantment table uses up to 15 bookshelves. You can produce all counts up to 15 by using groups of 1, 2, 4, and 8 bookshelves; the combinations of these are just binary numbers.
Here's a nice symmetric pattern for the groups, if you like that sort of thing.
Here's my own build of that pattern, with the 8-bookshelf group deployed. (In case you're wondering about the dark/sunlit aspect, I usually have a ring of slabs on top to prevent spawning, but it hides the pattern so I removed it for this picture.)
Here's a few pictures of the wiring for controlling the groups. I removed a casing around the pistons which prevents light from getting up into the room (that one upper-slab is needed to avoid cutting a wire).
This picture shows the topmost set of torches controlling the pistons, and the wires to the 1 group and half of the 4 group:
Here is the other side of the 4 group.
The 8 group is the most complex as it needs a lot of branching. It is fed from low in the center. There's redstone on top of the 4 sandstone blocks the repeaters are feeding into, which is what controls the pairs of torches at each corner which are directly under the top ring.
The extra repeater on the left of center is just to produce an aesthetic delay in the order the bookshelves rise.
The 2 group just cuts across the center of the top ring like
Every sandstone block in the pictures is either supporting a redstone element or carrying a signal; stone blocks are just the floor and walls.
On the other hand, if you just want an ultra-compact system with less underground wiring, another configuration is to run a single redstone wire around a ring of pistons, and then use variable signal strengths — the signal dies out at some point before reaching all the pistons, so the signal strength at the input directly sets the number of extended pistons.
However, it's tricker to make a small control interface for this: the simplest is a row of 15 separate levers (all spaced out along the input wire), which you toggle only one of.
If you seek to create an easily controllable setup to get varying maximum enchantment levels, removing bookshelves is not the only way, another is to block them.
Enchantment table detects a supporting bookshelf if there are air blocks between them. Hence you can easily control how many bookshelves affect your enchanting table by placing and collecting torches. (Or raising cakes with pistons. Cakes sap magic energies, true story.)
Lower bookshelves require lower block to be air, higher bookshelves require both blocks, on the foot level and head level, to be air. Horizontal dependencies are as follows (capital letters are shelves, small letters are air blocks that control those shelves):
Below are "weights" of air blocks, i.e. number of possible shelves a given air block connects to the table:
By arranging your bookshelves in a certain way, you can make your enchantment area easily and precisely controlled by several torches. Taking Kevin Reid's correctly proposed combination of 8, 4, 2 and 1 shelves, something like the following can be done (controlled entirely by ground-level torches):