我有这段代码,可以执行以下操作:打开一个Csv文件,看起来像这样,但是只有更多行
这是代码
import pandas as pd
import os
df= pd.read_csv(r"C:/Users/z647818/Desktop/tree/tree.csv", delimiter=";", encoding='unicode_escape')
df['Numbers'] = df['Numbers'].str.split(',').str[0]
df['Numbers'] = df['Numbers'].astype('int64', copy=False)
def scatterGraph(str1):
dfstr = df[df['Description'] == str1]
dfstrval = df[df['Description'] == str1]['Numbers']
print(dfstrval)
dfstr.plot(kind='scatter', x='Numbers', y='Numbers')
str1 = 'Journey has started' # In order to search for any other string just put that string here.
scatterGraph(str1)
代码有什么作用?
转到“说明”列,按字符串名称Journey has started
进行过滤,并绘制“数字”列中的所有值
结果看起来像这样。
我正在寻找一些帮助,以帮助您将相同的过滤结构转换为按列中的某个字符串,然后将值绘制为K均值