Sort by labels along an axis df.sort_index() Set index a of Series s to 6 s = 6 Droppingĭrop values from rows (axis=0) s.drop()ĭrop values from columns(axis=1) df.drop('Country', axis=1) Use filter to adjust DataFrame df>1200000000] Setting Select a single column of subset of columns df.ix Select single row of subset of rows df.ix Select single value by row and column labels df.loc(, ) Select single value by row and and column df.iloc(, ) Pd.read_sql_query(SELECT * FROM my_table ', engine)ĭf.to_sql('myDf', engine) Selection GettingĢ Brazil Brasilia 207847528 Selecting', Boolean Indexing and Setting By Position Pd.read_sql(SELECT * FROM my_table, engine) (read_sql()is a convenience wrapper around read_sql_table() and read_sql_query()) from sqlalchemy import create_engineĮngine = create_engine('sqlite:///:memory:') Asking For Help help(pd.Series.loc) I/O Read and Write to CSV pd.read_csv('file.csv', header=None, nrows=5)ĭf.to_csv('myDataFrame.csv') Read multiple sheets from the same file xlsx = pd.ExcelFile('file.xls')ĭf = pd.read_excel(xlsx, 'Sheet1') Read and Write to Excel pd.read_excel('file.xlsx')ĭf.to_excel('dir/myDataFrame.xlsx', sheet_name='Sheet1') Read and Write to SQL Query or Database Table Please note that the first column 1, 2, 3 is the index and Country, Capital, Population are the Columns. A one-dimensional labeled array capable of holding any data type s = pd.Series(, index=) AĪ two-dimensional labeled data structure with columns of potentially different types data = ĭf = pd.DataFrame(data,columns=)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |