Professional Documents
Culture Documents
pickled_data = pickle.load(file)
Importing Data Cheat Sheet >>> data_array.dtype #Data type of array elements
df_sas = file.to_data_frame()
> Exploring Dictionaries
>>> np.info(np.ndarray.dtype)
>>> help(pd.read_csv)
Querying relational databases with pandas
> Stata File
>>> print(mat.keys()) #Print dictionary keys
> Text Files >>> data = pd.read_stata('urbanpop.dta') >>> for key in data.keys(): #Print dictionary keys
print(key)
meta
quality
>>>
>>> print(file.closed) #Check whether file is closed
print(file.readline())
names=['Country']) Detector
print(file.readline()) To access the sheet names, use the sheet_names attribute: Duration
>>> data.sheet_names
GPSstart
Observatory
UTCstart
>>> print(data['meta']['Description'].value)
Querying Relational Databases !ls #List directory contents of files and directories
con.close()
OS Library
>>> filename = 'titanic.csv'
Using the context manager with >>> import os
delimiter=',',
>>> with engine.connect() as con:
dtype=None)
df = pd.DataFrame(rs.fetchmany(size=5))
Importing Flat Files with Pandas Querying relational databases with pandas >>> os.remove("test1.txt") #Delete an existing file