Restricting your result set fields
Liberator will always return a minimum default set of columns for each dataset (and that can vary slightly from dataset to dataset but includes at a minimum _seq, muts, timestamp and symbol). Some datasets can have hundreds of columns and you may want only one or two. If you are on a slower internet connection you may want to cut the response to as small a size as possible to improve your download time.
To reduce the number of columns returned simply pass the field parameter with a list of the columns you require ie…
df = liberator.get_dataframe(liberator.query( name = 'daily_bars', as_of ='2024-07-24', back_to = '2024-07-22', symbols = ['AAPL','GOOGL'], fields = ['Open','Close']))
df
Note that liberator places your selected columns at the front of the dataframe.
If you are not sure of the column names available in a dataset you can either use the liberator.datasets(schema = True)['nameOfDataset'] or you can simply pull a small amount of data into a dataframe and use the columns command…
df.columns
or
list(df.columns)
or
print(list(df.columns))
Output for 'daily_bars' :
['_seq', '_dsname', 'timestamp', 'msg_len', 'msg', 'muts', 'symbol', 'length', 'open', 'high', 'low', 'close', 'volume', 'vwap', 'bvwap', 'spread', 'bidvol', 'askvol', 'count', 'avgdelta', 'Date', 'Time', 'Hour', 'DateTime', 'DateHour']