Pandas Notes
Pandas Notes
Pandas Notes
code
else:
print(’no exception’)
finally:
this clause always exsicuted
f=open("name","arw")
Print(f.realline)
Print(f.read)
Print(f.write)
for x in f:
print(x)
f.close()
PANDAS
functions
import pandas as pd
1- pd.series
2- pd.DataFrame
3-pd.Loc[]
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = pd.DataFrame(data)
print(df.loc[0])
ANS=
calories 420
duration 50
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = pd.DataFrame(data, index = ["day1", "day2", "day3"])
print(df)
ANS=
calories duration
day1 420 50
day2 380 40
day3 390 45
3refferance with 4
print(df.loc["day2"])
ans=
calories 380
duration 40
5-pd.read_csv(’data.csv’)
6-pd.read_json(’data.json’)
import pandas as pd
df = pd.read_csv(’data.csv’)
df = pd.read_json(’data.json’)
print(df.to_string()) or print(df)
7-pd.options.display.max_rows
print(pd.options.display.max_rows)
8- df.head()
9- df.tail()
import pandas as pd
df = pd.read_csv(’data.csv’)
print(df.head(10))
10- df.info()
print(df.info())
_________________
try:
code
else:
print(’no exception’)
finally:
this clause always exsicuted
f=open("name","arw")
Print(f.realline)
Print(f.read)
Print(f.write)
for x in f:
print(x)
f.close()
PANDAS
functions
import pandas as pd
1- pd.series
2- pd.DataFrame
3-pd.Loc[]
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = pd.DataFrame(data)
print(df.loc[0])
ANS=
calories 420
duration 50
import pandas as pd
data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = pd.DataFrame(data, index = ["day1", "day2", "day3"])
print(df)
ANS=
calories duration
day1 420 50
day2 380 40
day3 390 45
3refferance with 4
print(df.loc["day2"])
ans=
calories 380
duration 40
5-pd.read_csv(’data.csv’)
import pandas as pd
print(df.to_string()) or print(df)
7-pd.options.display.max_rows
print(pd.options.display.max_rows)
8- df.head()
9- df.tail()
import pandas as pd
df = pd.read_csv(’data.csv’)
print(df.head(10))
10- df.info()
_________________