<jupyter_start><jupyter_text>6) Opeations<jupyter_code>import numpy as np
import pandas as pd
d = {'col1':[1,2,3,4],
     'col2':[45,55,65,45],
     'col3':['asd','jkl','qwe','xyz']}
df=pd.DataFrame(d)
df
df['col2'].unique()
len(df['col2'].unique())
df['col2'].nunique()
df['col2'].value_counts()
# apply method
def times5(x):
  return x*5
times5(10)
df['col1'].sum()
df
df['col1'].apply(times5)
df['col3'].apply(len)
df.drop('col1',axis=1)
df.columns
df.index
df.sort_values('col2')
df.isnull()<jupyter_output><empty_output><jupyter_text>7) Reading and Writing files in Pandas  Reading and writing CSV Files<jupyter_code>import pandas as pd
pwd
pd.read_csv('/content/test.csv')
b = pd.read_csv('/content/test.csv')
b
d = {'name':['Sara','Tom','Mark','Vinny'],
     'score':[75,80,85,90],
     'number':[22,25,27,30]}
d
df = pd.DataFrame(d)
df
df.to_csv('test_2.csv')
pd.read_csv('/content/test_2.csv',index_col=0)<jupyter_output><empty_output><jupyter_text>Reading and writing Excel files<jupyter_code>pd.read_excel('/content/test.xlsx',index_col=0,sheet_name='Sheet1')
df
df.to_excel('test_2.xlsx',sheet_name='Sheet1')
pd.read_excel('/content/test_2.xlsx',index_col=0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21, 'fraction_numerical': 0.04833333333333333, 'mean_word_length': 7.766423357664234, 'pattern_counts': {'":': 0, '<': 13, '<?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': '223213', 'license': 'MIT', 'n_tokens_mistral': 541, 'n_tokens_neox': 518, 'n_words': 71, 'path': '15DataAnalysisWithPandas2.ipynb', 'repo_name': 'MBadriNarayanan/NaturalLanguageProcessing', 'size': '1200'}