Created
July 27, 2015 10:30
-
-
Save Ray901/b654ef8fc2c2e259603b to your computer and use it in GitHub Desktop.
use python to create dataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import string , random | |
def randomword(length): | |
return ''.join(random.choice(string.uppercase[0:5]) for i in range(length)) | |
df1 = pd.DataFrame(list(randomword(50)),columns=['user']) | |
df2 = pd.DataFrame(np.random.randint(100, size=(50,2)),columns=['G1','G2']) | |
DF = pd.concat([df1,df2],axis=1) | |
print DF.groupby('user').agg([np.sum,np.mean]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment