Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dict to csv keys as rows and subkey as columns in python

import pandas as pd
dic = {"Location1":{"a":1,"b":2,"c":3},"Location2":{"a":4,"b":5,"c":6}, "Location3":{'e':7,'f':8, 'g':9, 'h':10}, "Location4":{'e': 2, 'f': 3, 'g': 4, 'h': 5}}
pd.DataFrame.from_dict(dic, orient='index').to_csv('temp.csv')
Comment

PREVIOUS NEXT
Code Example
Python :: repalce na with mean per group 
Python :: pycharm writing issue 
Python :: python get function from string name 
Python :: ValueError: unknown is not supported in sklearn.RFECV 
Python :: python ask for real values until negative value diplay highest and lowest 
Python :: how to create a leaderboard on python 3.8.1 
Python :: withdraw() opposite tjinter 
Python :: python program to get equally distributed number from given range 
Python :: Mat.at(row,col) Opencv 
Python :: python in a nutshell 
Python :: docker python heelo world doesnt print anything 
Python :: roganrola 
Python :: python read stdin to string 
Python :: pandas resample fill missing values 
Python :: DRf Representation 
Python :: fibonacci sequence python genorator 
Python :: start models 
Python :: differentate derivative differentation 
Python :: get all methods of an instance 
Python :: powershell open file with default program 
Python :: codeforces 233 a solution python 
Python :: mechanize python LE #3 
Python :: get users except superuser django 
Python :: how to catch chunkedencodingerror 
Python :: remove duplicate rows in pandas 
Python :: flask crud generator 
Python :: how to make a new df from old 
Python :: unittest run one test 
Python :: Example pandas.read_hdf5() 
Python :: droping columns 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =