Question

In: Computer Science

I want to create a seating chart that I can assign an 'X' to if a...

I want to create a seating chart that I can assign an 'X' to if a seat is purchased. I want to use a numpy array, but am having trouble figuring out how to write it the way I want it. I want it 4 X 15, but with string values instead of all the same value or a range. i would like this. can I do it with numpy? also I want the columns lined up when i do a test print, or write to a text file if possible.

['A1', 'B1','C1','D1'
  'A2', 'B2','C2','D2'
  'A3', 'B3','C3','D3'
  'A4', 'B4','C4','D4'
  'A5', 'B5','C5','D5'
  'A6', 'B6','C6','D6'
  'A7', 'B7','C7','D7'
  'A8', 'B8','C8','D8'
  'A9', 'B9','C9','D9'
  'A10', 'B10','C10','D10'
  'A11', 'B11','C11','D11'
  'A12', 'B12','C12','D12'
  'A13', 'B13','C13','D13'
  'A14', 'B14','C14','D14'
  'A15', 'B15','C15','D15']

Solutions

Expert Solution

As the data you have provided don't have comma or a bracket after the fourth element. so you first have to make a list of 60 elements then can do this way code is provides.

import numpy as np
l=[['A1', 'B1','C1','D1'],
   ['A2', 'B2','C2','D2'],
  ['A3', 'B3','C3','D3'],
  ['A4', 'B4','C4','D4'], 
  ['A5', 'B5','C5','D5'],
  ['A6', 'B6','C6','D6'],
  ['A7', 'B7','C7','D7'],
  ['A8', 'B8','C8','D8'],
  ['A9', 'B9','C9','D9'],
  ['A10', 'B10','C10','D10'],
  ['A11', 'B11','C11','D11'],
  ['A12', 'B12','C12','D12'],
  ['A13', 'B13','C13','D13'],
  ['A14', 'B14','C14','D14'],
  ['A15', 'B15','C15','D15']]
ch = np.chararray(4,15)
ch=l
print(l)

Output:-

[['A1', 'B1', 'C1', 'D1'], ['A2', 'B2', 'C2', 'D2'], ['A3', 'B3', 'C3', 'D3'], ['A4', 'B4', 'C4', 'D4'], ['A5', 'B5', 'C5', 'D5'], ['A6', 'B6', 'C6', 'D6'], ['A7', 'B7', 'C7', 'D7'], ['A8', 'B8', 'C8', 'D8'], ['A9', 'B9', 'C9', 'D9'], ['A10', 'B10', 'C10', 'D10'], ['A11', 'B11', 'C11', 'D11'], ['A12', 'B12', 'C12', 'D12'], ['A13', 'B13', 'C13', 'D13'], ['A14', 'B14', 'C14', 'D14'], ['A15', 'B15', 'C15', 'D15']]

You can do it using dataframe and can save it to a csv file. I am adding the code for the same. It will store the data in excel file which will show ith row for the corresponding seating plan.

import numpy as np
import pandas as pd
l=[['A1', 'B1','C1','D1'],
['A2', 'B2','C2','D2'],
['A3', 'B3','C3','D3'],
['A4', 'B4','C4','D4'],
['A5', 'B5','C5','D5'],
['A6', 'B6','C6','D6'],
['A7', 'B7','C7','D7'],
['A8', 'B8','C8','D8'],
['A9', 'B9','C9','D9'],
['A10', 'B10','C10','D10'],
['A11', 'B11','C11','D11'],
['A12', 'B12','C12','D12'],
['A13', 'B13','C13','D13'],
['A14', 'B14','C14','D14'],
['A15', 'B15','C15','D15']]
charar = np.chararray(4,15)
charar=l
print(l)
X=pd.DataFrame(data=l)
X.to_csv(<filename>,index=False)


Related Solutions

In the chart below, assign the directional effect (I = increase, D = decrease, or NE...
In the chart below, assign the directional effect (I = increase, D = decrease, or NE = no effect) of each of the following six transactions on the components of the book value of common shareholders’ equity. a. Small stock dividend declared and issued. b. 2-for-1 stock split announced and issued. c. Stock options granted. d. Recognition of compensation expense on stock options. e. Stock options exercised. f. Stock options expired. Item Common Stock Additional Paid-In Capital Deferred Compensation Retained...
In the chart below, assign the directional effect (I = increase, D = decrease, or NE...
In the chart below, assign the directional effect (I = increase, D = decrease, or NE = no effect) of each of the following six transactions on the components of the book value of common shareholders’ equity. a. Small stock dividend declared and issued. b. 2-for-1 stock split announced and issued. c. Stock options granted. d. Recognition of compensation expense on stock options. e. Stock options exercised. f. Stock options expired. Item Common Stock Additional Paid-In Capital Deferred Compensation Retained...
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write...
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write a program to do it Enter your score: 85 Your grade is a “B” 0-------------------60---------70-------------80-----------90-------------100 F D C B A MUST use nested if-else statements.
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
Based on the information below, create a project schedule (Gantt Chart). Assign tasks to either Workgroup...
Based on the information below, create a project schedule (Gantt Chart). Assign tasks to either Workgroup or Individual. Project: Vacation Team: "Workgroup 1", "Individual" Start/End: February 19 - May 26 START A. February 19: Vacation participation must be confirmed Time allotted: 7 days i. Confirm participation Time needed: 1 day ii. Research vacation deals Time needed: 1 days iii. Decide on destination Time needed: 2 days iv. Create travel list Time needed: 1 day Slack available: 2 days B. February...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input system for a university student, where they put the season and year of when they started their uni course. For example the system will ask "What year did you start your degree?", the user will input "Autumn/2022" as a string. Now from a string format as shown, it should take that user input and calculate for example +2 or +3 years to the date....
A theater seating chart is implemented as a table of ticket prices, like this C1 C2...
A theater seating chart is implemented as a table of ticket prices, like this C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 R1 10 10 10 10 10 10 10 10 10 10 R2 10 10 10 10 10 10 10 10 10 10 R3 10 10 10 10 10 10 10 10 10 10 R4 10 10 20 20 20 20 20 20 10 10 R5 10 10 20 20 20 20 20 20 10 10 R6...
I want to create an app which a user can talk to and get emotional feedback...
I want to create an app which a user can talk to and get emotional feedback in a form of a conversation. So, a user can talk about how stressful their day was, and my app should reply accordingly so that the user feels better. I want to know what methods(pyschologically) I can apply on my bot so that the user feels satisfied. In short, is there any psychological therapy term which deals with such conversations? Also, what all illnesses...
I want to draw a sphere and I want to rotate it, How can I do...
I want to draw a sphere and I want to rotate it, How can I do it in JOGL? ( I am working on a program to visualize the sun ) please provide a pic of the code.
In python using tkinter, I want to create a program. The program can have various classes...
In python using tkinter, I want to create a program. The program can have various classes and methods but I want it to have circles, triangles, and squares. Each shape movies in a certain way, like circles can move linearly, triangles can be affected by gravity, and squares can only go up and down. If the shapes get too close to one another then they disappear and a new shape appears somewhere else. I want this program to run continuously.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT