PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lincs/io/stats.py

https://bitbucket.org/kljensen/kmj_lincs
Python | 19 lines | 8 code | 2 blank | 9 comment | 0 complexity | ec2c4d413b59c97baf406b7cd0012539 MD5 | raw file
  1. import pandas
  2. def read_data_file(path, sheet_name, signals, cell_count_col):
  3. """ Reads an Excel file into a pandas DataFrame and deletes
  4. all columns that aren't either a signal intensity or
  5. the cell_count_col.
  6. """
  7. xls_file = pandas.ExcelFile(path)
  8. data = xls_file.parse(sheet_name)
  9. cols_to_keep = set(signals + [cell_count_col])
  10. for col in data.columns:
  11. if col not in cols_to_keep:
  12. del data[col]
  13. # Make sure the cell_count_col is always "cell_count"
  14. #
  15. data.rename(columns={cell_count_col: "cell_count"}, inplace=True)
  16. return data