简体   繁体   English

我如何根据 pandas 中特定列的用户输入获得列的总和

[英]How do i get the sum of a column based on the user input of that particular column in pandas

import json import requests import pandas as pd def get_additonal_data(): import pandas as pd file_path = '/Users/CIS5357/Assignments/' data = file_path + 'grades.csv' df_grades = pd.read_csv(data) print (df_grades) return df_grades def do_functions(df_grades): import pandas as pd user_input_grade = input(str("enter the grade: ")) Print_grades = df_grades.at[user_input_grade].sum() print(Print_grades) df_grades = get_additonal_data() do_functions(df_grades) import json import requests import pandas as pd def get_additonal_data(): import pandas as pd file_path = '/Users/CIS5357/Assignments/' data = file_path + 'grades.csv' df_grades = pd.read_csv(data) print (df_grades) return df_grades def do_functions(df_grades): import pandas as pd user_input_grade = input(str("输入等级:")) print_grades = df_grades.at[user_input_grade].sum() print(Print_grades) df_grades = get_additonal_data() do_functions(df_grades)

import pandas as pd
import requests

file_path = '/Users/CIS5357/Assignments/'
data = file_path + 'grades.csv'
df_grades = pd.read_csv(data)
user_input_grade = input("enter the grade: ")
Print_grades = df_grades[user_input_grade].sum()
print(Print_grades)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据另一列的日期条件获取熊猫数据框中特定列的值? - How do I get the values of a particular column in a pandas dataframe based on a date condition on another column? 如何使用 Pandas 根据数据框中另一列的值获取 2 列的总和 - How do I use Pandas to get the sum of 2 columns based on the value of another column in a dataframe 如何使用pandas基于另一列[SoldDate]找到特定列[Model]的计数? - How do I find the count of a particular column [Model], based on another column [SoldDate] using pandas? 如何从数据框python3中获取特定列的用户输入的Pandas - How to get the user Input in Pandas for a particular column from the dataframe python3 如何对熊猫中特定列的值求和 - How to sum the values of a particular column in pandas 如何在熊猫中创建总和行和总和列? - How do I create a sum row and sum column in pandas? 如何基于另一列的滚动总和获得列值? - How do I get a column value based on rolling sum of another column? 如何根据 Pandas 中的列名对一组列求和? - How do I sum across group of columns based on column names in Pandas? 使用 pandas,如何检查列中是否存在特定序列? - Using pandas, how do I check if a particular sequence exist in a column? 如何从日期栏中获取每个股票的年数总和?(熊猫) - How do I get the sum of years from date column in reference to each ticker?(Pandas)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM