<jupyter_start><jupyter_text>Getting Started with simple pandas Here I reproduced some of the operation that appeared in *Python for Data Analysis*.Hope this could help you get familiar with simple pandas Also, since there is no good visualization for simple pandas right now, I have transfered each of the results to pandas.<jupyter_code>import spandas as spd
import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>1 Series<jupyter_code>obj = spd.Series([4, 7, -5, 3])
pd.Series(obj.values, obj.index)
obj.values
obj.index
obj2 = spd.Series([4, 7, -5, 3], index=['d', 'b', 'a', 'c'])
tmp = obj2[obj2.index == 'a']
pd.Series(tmp.values, tmp.index)
obj2.set_by_index('d', 6)
pd.Series(obj2.values, obj2.index)
tmp = obj2[obj2 > 0]
pd.Series(tmp.values, tmp.index)
tmp = obj2 * 2
pd.Series(tmp.values, tmp.index)
sdata = {'Ohio': 35000, 'Texas': 71000, 'Oregon':16000, 'Utah': 5000}
obj3 = spd.Series(sdata)
pd.Series(obj3.values, obj3.index)
states = ['California', 'Ohio', 'Oregon', 'Texas']
obj4 = spd.Series(sdata, index=states)
pd.Series(obj4.values, obj4.index)
tmp = obj4.isnull()
pd.Series(tmp.values, tmp.index)
# the add in pandas may results in unexpected result...
# therefore, we just add two series elementwise according to their row number and maintain the index of the left
a = spd.Series([1, 2, 3], [1, 1, 2])
b = spd.Series([1, 2, 3], [2, 2, 2])
print(a + b)<jupyter_output>1      2
      1      4
      2      6
dtype: int32<jupyter_text>2 DataFrame<jupyter_code>data = {'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada', 'Nevada'], 
        'year': [2000, 2001, 2002, 2001, 2002, 2003], 
        'pop': [1.5, 1.7, 3.6, 2.4, 2.9, 3.2]}

frame = spd.DataFrame(data)

pd.DataFrame(frame.dict, frame.index)
frame = spd.DataFrame(data, columns=['year', 'state', 'pop'])
pd.DataFrame(frame.dict, frame.index)
frame2 = spd.DataFrame(data, columns=['year', 'state', 'pop', 'debt'], 
                      index=['one', 'two', 'three', 'four', 'five', 'six'])
pd.DataFrame(frame2.dict, frame2.index)
frame2.columns
print(frame2[['state']])
tmp = frame2[frame2.index == 'three']
pd.DataFrame(tmp.dict, tmp.index)
frame2[['debt']] = 16.5
pd.DataFrame(frame2.dict, frame2.index)
frame2[['debt']] = np.arange(6.)
pd.DataFrame(frame2.dict, frame2.index)
val = spd.Series([-1.2, -1.5, -1.7], index=['four', 'two', 'five'])
frame2[['debt']].set_by_index(val.index, val.values)
pd.DataFrame(frame2.dict, frame2.index)
frame2[['eastern']] = frame2[['state']] == 'Ohio'
pd.DataFrame(frame2.dict, frame2.index)
del frame2[['eastern']]
pd.DataFrame(frame2.dict, frame2.index)
frame2.columns
tmp = frame2.T
pd.DataFrame(tmp.dict, tmp.index)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18175074183976261, 'fraction_numerical': 0.051557863501483676, 'mean_word_length': 4.875816993464053, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, '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': '33325', 'license': 'MIT', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1027, 'n_words': 261, 'path': 'introduction.ipynb', 'repo_name': 'zhuzilin/simple-pandas', 'size': '2696'}