'Python: Add row into pandas dataframe with array as column value instead of multiple rows?
I want to handle with a table of following form:
example = {'Assumptions': 1, 'Index': 5, 'Proposition': '¬p∧ ¬ (¬p)', 'Premisses': [4, 3], 'Rule': '∧I'}
The command
example = pd.DataFrame(example)
gets:
Assumptions Index Proposition Premisses Rule
0 1 5 ¬p∧ ¬ (¬p) 4 ∧I
1 1 5 ¬p∧ ¬ (¬p) 3 ∧I
but my aim is to get some table of following form:
Assumptions Index Proposition Premisses Rule
0 1 5 ¬p∧ ¬ (¬p) [3, 4] ∧I
Is their a way to do that?
Solution 1:[1]
You could wrap it in a list first, then construct the DataFrame:
df = pd.DataFrame([example])
Output:
Assumptions Index Proposition Premisses Rule
0 1 5 ¬p? ¬ (¬p) [4, 3] ?I
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
