“Pandas las Wörterbuch” Code-Antworten

Pandas DataFrame aus dem Diktat

data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
pd.DataFrame.from_dict(data)
Shaunak

Konvertieren Sie das DICT in DataFrame

#Lazy way to convert json dict to df

pd.DataFrame.from_dict(data, orient='index').T
Magnificent Moth

Pandas las Wörterbuch

data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
>>> pd.DataFrame.from_dict(data)
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
Courageous Cod

Von Pandas zum Wörterbuch

df = pd.DataFrame({'col1': [1, 2],
...                    'col2': [0.5, 0.75]},
...                   index=['row1', 'row2'])
>>> df
      col1  col2
row1     1  0.50
row2     2  0.75
>>> df.to_dict()
{'col1': {'row1': 1, 'row2': 2}, 'col2': {'row1': 0.5, 'row2': 0.75}}
Courageous Cod

Ähnliche Antworten wie “Pandas las Wörterbuch”

Fragen ähnlich wie “Pandas las Wörterbuch”

Weitere verwandte Antworten zu “Pandas las Wörterbuch” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen