Python-Starprogram O API
Python-Starprogram O API
myfile=open(“filepath.text”,”r”)
df=myfile.read()
myfile.clos()
df=file1.read()
print(file1.closed)
print(df)
3-write
import pandas as pd
fl=”path.csv”
df=pd.read_csv(“fl”)
Case to use
A- CSV file
Import pandas as pd
file_path=(“filepath.csv”)
df=pd.read_csv(file_path)
df.head()
B-Excel file
file_path=(“filepath.xlsx”)
df=pd.read_excel(file_path)
df.head()
use dictionary
student_spe_meca_ufr1={”licence3”:[”amine”,”bechtaoui”,”tounsi”,”les
francais”],”master1":[”amine”,”bechtaoui”,”tounsi”,”les francais”],”master2":
[[”amine”,”bechtaoui”,”tounsi”,”les francais”]}
df= pd.DataFrame(student_spe_meca_ufr1)
4_ Extract 2 coulmns
O=df[[”licence3",”master1"]] / /or 3 or more
5- Change index
df2=df
df2.index[”2018",”2019",2020"]
9 - Extract dataframe
Z1=df.iloc[0:5, 0:3] // 6 first rows start from 0 index and 3 first coulumn
start from 0 index )
Or
6- Methode unique
2015 8 15 7 15 23
2016 11 14 9 10 25
2017 14 16 12 13 30
2018 16 20 13 17 36
import pandas as pd
file_path=”filepath.csv”
df=pd.read_csv(file_path”)
df.head()
df.loc[2:5,”Album”]
1- API
Request Request
import requests
url=’https://ibm.com/’
r=requests.get(url)
r.statut_code >200
header[”Content-type”]