Reading files and open files in Python
import pandas as pd
import matplotlib.pyplot as plt
import numpy as ny
import urllib.request
url = 'https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%204/data/example1.txt'
filename = 'example1.txt'
urllib.request.urlretrieve(url, filename)
with open("example.txt","r") as file1:
file_stuff = file1.read()
print(file1.read(4))
print(file_stuff)
examp2 = '/Example2.txt'
with open(examp2,'w') as writefile:
writefile.write('This is a lineA and B')
with open(examp2,'r') as readfile:
file1 = readfile.read()
print(file1)
with open(examp2,'w') as file1:
file1.write('what and era')
file2 = file1.write('A communist\n should go back\n from our country')
with open(examp2,'r') as newfile:
print(newfile.read())
!pip install xlrd
!pip install openpyxl
import pandas as pd
list1={'a':[11,13,14,15],'b':[43,45,34,23]}
df=pd.DataFrame(list1)
df.head(3)
x=df['a','b']
df.ix[0,0]
df.ix[0,1]
df.ix[2,1]
z=df.ix[0:2,0:3]
df['released'].unique()
csv_path = 'https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%204/data/TopSellingAlbums.csv'
df=pd.read_csv(csv_path)
df.head(5)
Comments
Post a Comment