Pandas Session 5 Code For Video Click Fahad Hussain CS
Hi, Welcome to Fahad Hussain CS blog, do not forget to subscribe and follow the blog and YouTube channel Fahad Hussain CS
Code:
import numpy as np
import pandas as pd
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
df = pd.read_csv('ex1.csv')
df.head()
pd1 = pd.read_table('ex1.csv',sep=',')
pd1
pd1 = pd.read_csv('ex2.csv',header=None)
pd1
pd1 = pd.read_csv('ex2.csv',names=['a','b','c','d','message'])
pd1
names=['a','b','c','d','message']
pd3 = pd.read_csv('ex2.csv',names=names, index_col='message')
pd3
parsed = pd.read_csv('csv_mindex.csv',index_col=['key1','key2'])
parsed
list(open('ex3 (1).txt'))
result = pd.read_table('ex3 (1).txt', sep='\s+')
result
print(pd.isnull(result))
result1 = pd.read_csv('ex5.csv',na_values=['NULL'])
result1
data.to_csv(sys.stdout, na_rep='NULL')
print(data)
aa = data.to_csv(sys.stdout, index=False, header=False)
print(aa)
data.to_csv(sys.stdout, index=False, columns=['a', 'b', 'c','d'])
import numpy as np
dates = pd.date_range('1/1/2000', periods=7)
ts = pd.Series(np.arange(7), index=dates)
print(ts)
print(ts.to_csv('tseries.csv'))
if posiible , please upload the csv file as well for better understanding
ReplyDelete