Просмотр содержимого документа
«Практическое занятие №52»
Практическое занятие №52 (1И)
Тема: Практика вычисления описательных статистических величин в Python Pandas
Цель работы: формирование теоретических и практических навыков работы на языке программирования Python
Оборудование: компьютер с установленной операционной системой Windows, подключение к сети Интернет
Время работы 2 часа
Ход работы
Задание 1.
# importing pandas as pd
import pandas as pd
# Creating the timestamp
ts = pd.Timestamp('02-06-2018')
# Print the timestamp
print(ts)
Задание 2.
# importing pandas as pd
import pandas as pd
# Let's create a dataframe
df = pd.DataFrame({'City':['Lisbon', 'Parague', 'Macao', 'Venice'],
'Event':['Music', 'Poetry', 'Theatre', 'Comedy'],
'Cost':[10000, 5000, 15000, 2000]})
# Let's create an index using Timestamps
index_ = [pd.Timestamp('01-06-2018'), pd.Timestamp('04-06-2018'),
pd.Timestamp('07-06-2018'), pd.Timestamp('10-06-2018')]
# Let's set the index of the dataframe
df.index = index_
# Let's visualize the dataframe
print(df)
Задание 3.
# importing pandas as pd
import pandas as pd
# Let's create the Period
# We have created a period
# of a month
pr = pd.Period('06-2018')
# Let's print the period
print(pr)
Задание 4.
# importing pandas as pd
import pandas as pd
# Let's create a dataframe
df = pd.DataFrame({'City':['Lisbon', 'Parague', 'Macao', 'Venice'],
'Event':['Music', 'Poetry', 'Theatre', 'Comedy'],
'Cost':[10000, 5000, 15000, 2000]})
# Let's create an index using Periods
index_ = [pd.Period('02-2018'), pd.Period('04-2018'),
pd.Period('06-2018'), pd.Period('10-2018')]
# Let's set the index of the dataframe
df.index = index_
# Let's visualize the dataframe
print(df)