Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Example pandas.read_hdf5()

def test_write_data_frame(hdf_file_path):
    key = hdf.EntityKey('cause.test.prevalence')
    data = build_table([lambda *args, **kwargs: random.choice([0, 1]), "Kenya", 1],
                       2005, 2010, columns=('age', 'year', 'sex', 'draw', 'location', 'value'))

    non_val_columns = data.columns.difference({'value'})
    data = data.set_index(list(non_val_columns))

    hdf._write_pandas_data(hdf_file_path, key, data)

    written_data = pd.read_hdf(hdf_file_path, key.path)
    assert written_data.equals(data)

    filter_terms = ['draw == 0']
    written_data = pd.read_hdf(hdf_file_path, key.path, where=filter_terms)
    assert written_data.equals(data.xs(0, level='draw', drop_level=False)) 
Comment

PREVIOUS NEXT
Code Example
Python :: Find Factors of a Number Using Class 
Python :: Code Example of Comparing None with False type 
Python :: Python Switch case statement using if-elif-else 
Python :: Simple Python Permutation Passing argument as the second parameter 
Python :: tuple with mixed data types 
Python :: Example of Python Strings with indexing 
Python :: Python 2 vs Python 3 Print Statement 
Python :: python log max age linux delete old logs 
Python :: write console output in same place 
Python :: sys exit out of loop 
Python :: python count files fast 
Python :: strain rate 
Python :: disable chrome console errors selenium 
Python :: dataframe ggplot rownames order 
Python :: How to find text of h2 tag in python requests-html 
Python :: Python NumPy atleast_1d Function Example 02 
Python :: geopandas nc file 
Python :: 123bum123 
Python :: Python NumPy block Function Example by using simple array 
Python :: search recurse sub-folders using glob.glob module python 
Python :: torch mean of tensor 
Python :: object at being output python 
Python :: how to split a string every 2 characters python 
Python :: pymenu template 
Python :: # remove sensitive information like name, email, phone no from text 
Python :: xampp python 
Python :: knn compute_distances_two_loop 
Python :: qmenu 
Python :: make python present number in sciencetifc 
Python :: Flask application displaying list of items from SQL database as text 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =