1)我怎麼在考慮到弦一柱
2)找到一個特定的字符串,怎麼會我覺得它的最大相應
3)如何計算串的數量爲每行中的列
我有sports.csv稱爲csv文件
import pandas as pd
import numpy as np
#loading the data into data frame
X = pd.read_csv('sports.csv')
感興趣的兩列是Totals
和Gym
柱:
Total Gym
40 Football|Baseball|Hockey|Running|Basketball|Swimming|Cycling|Volleyball|Tennis|Ballet
37 Baseball|Tennis
61 Basketball|Baseball|Ballet
12 Swimming|Ballet|Cycling|Basketball|Volleyball|Hockey|Running|Tennis|Baseball|Football
78 Swimming|Basketball
29 Baseball|Tennis|Ballet|Cycling|Basketball|Football|Volleyball|Swimming
31 Tennis
54 Tennis|Football|Ballet|Cycling|Running|Swimming|Baseball|Basketball|Volleyball
33 Baseball|Hockey|Swimming|Cycling
17 Football|Hockey|Volleyball
注意,Gym
列有各對應sport.I'm試圖找到一種方法,找到所有已棒球體育館的多串並找到最大的總數。不過,我只在有至少兩個其他體育場館興趣即我不想考慮:
Total Gym
37 Baseball|Tennis
是實際上你怎麼看文件? –
是的,該列的每項運動都由「|」分隔符號 – M3105
我在管道字符後看到一些空格,即| | Swimming | Cycling |',這是否也在您的文件或拼寫錯誤中? –