Infogain Interview Question

Create a long random string, then create a function that will create a dataframe from this string and in that dataframe the columns are the letters and their count.

Interview Answer

Anonymous

Oct 1, 2024

string= 'abshgfdgbtorsadsfdsgdsg' import pandas as pd def stringtodf(string): df = {i:string.count(i) for i in string} df = pd.DataFrame(list(df.items()),columns = ['Character','Count']) return df