Python Excel Print Colum

Hello,

Colum A B C D
index1 X1Q S1E F1T G1U
Index2 X2Q S2E F2T G2U
index3 X3Q S3E F3T G3U

Can you guys help me with this ?

import pandas as pd

df= pd.read_excel(file_path)

U = User_Input

#streamlit-examples : If U == 2T or 3T print(index)

I want to only search in colum โ€˜Cโ€™ , and ignore the first letter โ€™ F "

Output should be:

Index2 X2Q S2E F2T G2U
index3 X3Q S3E F3T G3U

Thank you !

I am unsure if you were looking for a drop down of if the user would type their search. In this case they can type โ€œ2Tโ€ or โ€œ3Tโ€ and it would show only their user info and if they type โ€œTโ€ it would show all of the other users info.

import streamlit as st
import pandas as pd
df=pd.read_csv(INSERT YOUR FILE PATH HERE)

user_input=st.text_input(โ€œUser Searchโ€)

if df[โ€œCโ€].str[1::].str.contains(user_input).any() and user_input!="":
st.write(df[df[โ€œCโ€].str[1::].str.contains(user_input)])
elif df[โ€œCโ€].str[1::].str.contains(user_input).any()==False:
st.write(โ€˜Value not found in Tableโ€™)
else:
st.write(โ€œPlease make a selectionโ€)

If what you wanted was a match for the last 2 letters, then that can be fixed with a drop down or just change โ€œcontainsโ€ to โ€œmatchโ€ like the example below:

df[โ€œCโ€].str[1::].str.contains(user_input) โ†’ df[โ€œCโ€].str[1::].str.match(user_input)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.