I have several csv columns that store lottery numbers and some other info, like date when the number was drawn. I need to get a dictionary as my output. So far I have been able to print number of occurrences in each column individually.
# Import libraries
import pandas as pd
from IPython.display import display
# Turn csv file into a pandas dataframe
df = pd.read_csv("LOTTOMAX.csv")
# Only select columns that I'm interested in. Csv file contains additional useless info.
selection = df[['NUMBER DRAWN 1', 'NUMBER DRAWN 2', 'NUMBER DRAWN 3', 'NUMBER DRAWN 4',
'NUMBER DRAWN 5', 'NUMBER DRAWN 6', 'NUMBER DRAWN 7']]
# Loop over columns and apply value_counts(). Output to terminal.
for col in selection.columns:
# I have included this to make terminal output more readable.
print('-' * 40 + col + '-' * 40 , end='\n')
display(selection[col].value_counts().to_string())
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)