[英]finding part of string in panda list
我有一個 pandas dataframe
,其中我有 1300 個大腦部分和 21 列有關它們的信息。 其中有一個structure_id_path
,一種大腦區域的樹狀結構。 我想找到其中包含例如“315”的每個 structure_id_path。
import pandas as pd
import numpy as np
df = pd.read_csv('/home/anja/Schreibtisch/Master/vonIsa/structure_tree_safe_2017.csv')
df[df.structure_id_path == '/997/8/567/688/695/315/184/526157192/']
當我這樣做時,我會找到具有特定structure_id_path
的大腦部分。
但是如果我想找到每個包含315
的structure_id_path
,它會返回一個空的 dataFrame,因為它找不到 315。
isocortex = '315'
x = structure_list[structure_list['structure_id_path'] == isocortex]
有沒有辦法找到它,比如*315?
嘗試:
df[df.structure_id_path.str.contains('/315/')]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.