Page 194 - Robotics and AI class 10
P. 194
Output:
0 Delhi
1 Mumbai
2 Chennai
3 Kolkata
dtype: object
• Creating series using labelled index
import pandas as pd
month=["June", "August", "October", "December"]
s4 = pd.Series(month, index = [6,8,10,12])
print(s4)
Output:
6 June
8 August
10 October
12 December
dtype: object
• Creating a Series from a Python dictionary
import pandas as pd
month={6:"June", 8:"August", 10:"October", 12:"December"}
s5 = pd.Series(dict)
print(s5)
Output:
6 June
8 August
10 October
12 December
dtype: object
• File access using Panda
Pandas can be accessed by using import :
import pandas as pd
To save the csv file into a variable :
s= pd.read_csv("Student data.csv")
To print the first five rows of the file:
print (s.head(5))
To print the first ten rows of the file:
print (s.head(10))
192 Touchpad Robotics & Artificial Intelligence-X

