<jupyter_start><jupyter_text>Session 2.1: Manipulating data with Pandas (live coding session)<jupyter_code>import pandas
mouse_data = pandas.read_csv('data/GRCm38.gff3', sep='\t')
mouse_data.head()
mouse_data.info()
mouse_data.describe()
mouse_data.head()
mouse_data_type = mouse_data.iloc[:,[2]]
type(mouse_data_type)
mouse_data_type.head()
mouse_data_type = mouse_data.iloc[:,2:3]
type(mouse_data_type)
mouse_data_type.head()
mouse_data['type'].head()
type(mouse_data['type'])
mouse_data['type'].unique()
feature_counts = mouse_data['type'].value_counts()
print(feature_counts)
%matplotlib inline
feature_counts.plot(kind='bar')
mouse_data.head()
mouse_data['len'] = mouse_data.end - mouse_data.start + 1
mouse_data.head()
mouse_exons = mouse_data[mouse_data.type=='exon']
mouse_exons.head()
long_mouse_exons = mouse_data[(mouse_data.type=='exon') & (mouse_data.len > 500)]
long_mouse_exons.head()
len(long_mouse_exons)<jupyter_output><empty_output><jupyter_text>ExercisePlot the length of exons from the mouse dataframe.<jupyter_code>mouse_exons.head()
%matplotlib inline
mouse_exons['len'].plot()
%matplotlib inline
mouse_exons.plot.scatter(x='start', y='len', title='mouse exons')<jupyter_output><empty_output><jupyter_text>Re-ordering columns and re-indexing data frame<jupyter_code>mouse_data.head()
reordered_mouse_data = mouse_data[['source', 'type', 'len']]
reordered_mouse_data.head()
mouse_exons.head()
reindexed_mouse_exons = mouse_exons.reset_index()
reindexed_mouse_exons.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14576493762311227, 'fraction_numerical': 0.007879185817465528, 'mean_word_length': 10.545454545454545, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '632032', 'license': 'Unlicense', 'n_tokens_mistral': 586, 'n_tokens_neox': 569, 'n_words': 80, 'path': '21_live_python_data.ipynb', 'repo_name': 'abotzki/python-data-science', 'size': '1523'}