
Twitter = [87.3, 150, 0.0, 2270.0, 264.0, 565.0, 834.0, 432.0, 0.0, 478.0, 198.0, 654.0, 98.7,
445.0, 1080.0, 697.0, 227.0, 0.0, 150.0, 932.0] create dataframe find sum find amount of elements

Ответы на вопрос

import pandas as pd
import numpy as np
def main():
twitter = [87.3, 150, 0.0, 2270.0, 264.0, 565.0, 834.0, 432.0, 0.0, 478.0, 198.0, 654.0, 98.7, 445.0, 1080.0, 697.0, 227.0, 0.0, 150.0, 932.0]
mass = pd.DataFrame(twitter)
summ = np.sum(mass)
amo = mass.shape
print(summ)
print(amo[0])
main()



To create a DataFrame from the list you provided, calculate the sum of the elements, and find the number of elements, you can use Python with the Pandas library. Here's how you can do it:
pythonimport pandas as pd
# Create a DataFrame from the given list
twitter_data = [87.3, 150, 0.0, 2270.0, 264.0, 565.0, 834.0, 432.0, 0.0, 478.0, 198.0, 654.0, 98.7, 445.0, 1080.0, 697.0, 227.0, 0.0, 150.0, 932.0]
df = pd.DataFrame({'Twitter': twitter_data})
# Calculate the sum of elements
total_sum = df['Twitter'].sum()
# Find the number of elements
num_elements = len(df)
# Print the results
print("DataFrame:")
print(df)
print("Sum of elements:", total_sum)
print("Number of elements:", num_elements)
This code creates a DataFrame from the provided list, calculates the sum of the elements in the 'Twitter' column, and finds the number of elements in the DataFrame. Make sure you have the Pandas library installed in your Python environment before running this code.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili