Commandline tool for printing tables to the terminal using pandas without firing up the interpreter.
Simply install:
cd panda-peek
pip install -e .
And then peek at your tables:
peek my_table.csv
Right now it just assumes the first column is the index and does not type-casting of columns (yet). It assumes this because it matches the default write function in pandas.
Feel free to help out and mutate!
- [ ] delimiter
- [ ] header
- [ ] comments
Specify which column is the index and the type of all the others
peek --col-dtypes index,string,float,int,bool my_df.csv
Explicitly:
peek --df-dtype my_df.dtype my_df.csv
peek -d my_df.dtype my_df.csv
Implicitly looking in my_df.dtype: (???)
peek -D my_df.csv
A python module which contains a dictionary mapping column names to datatypes:
from enum import Enum
from collections import namedtuple
class Sex(Enum):
MALE = 'male'
FEMALE = 'female'
CollectionRecord = namedtuple('CollectionRecord', ['museum', 'collection', 'drawer'])
specimen = {'specimen_names' : str,
'specimen_heights' : float,
'specimen_alive' : bool,
'specimen_sex' : Sex,
'specimen_collection' : CollectionRecord,
'collection_coordinates' : (float, float, float)}
And while in the same directory it will look in the file for the dtype dictionary you ask for:
peek -P specimen collection.csv
The first ten lines of a file (head):
peek -h 10 collections.csv
The last 30 lines (tail):
peek -t 10 collections.csv
First 3 lines and last 3 lines:
peek -h 3 -t 3 collections.csv
Between lines 8 and 20:
peek -f 8 -l 20 collections.csv
After line 12:
peek -f 12 collections.csv
Before line 16:
peek -l 16 collections.csv
From a .peek.view which is either lists or slices of indices or filter strings:
# my selection I care about
selection1 = [0,1,3,5,6]
# query for males
males = 'specimen_sex == male'
peek -I selection1 collections.csv
peek -I males collections.csv