In [5]:
import numpy as np
import pandas as pd
df = pd.read_csv('mycsv.csv')
In [11]:
df=pd.read_csv('mycsv.csv')
In [13]:
df.to_csv('mycsv2.csv',index=False)
In [20]:
df2=pd.read_excel('my1ex.xlsx',sheet_name='Sheet2')
In [14]:
pd.read_excel('Excel_Sample.xlsx',sheet_name='Sheet2')
Out[14]:
a | b | c | d | |
---|---|---|---|---|
0 | 0 | 1 | 2 | 3 |
1 | 4 | 5 | 6 | 7 |
2 | 666 | 9 | 10 | 11 |
3 | 12 | 13 | 14 | 15 |
In [21]:
df2.to_excel('ram1.xlsx',sheet_name='Sheet1')
In [14]:
data = {'A':['foo','foo','foo','bar','bar','bar'],
'B':['one','one','two','two','one','one'],
'C':['x','y','x','y','x','y'],
'D':[1,3,2,5,4,1]}
df1 = pd.DataFrame(data)
In [15]:
df1
Out[15]:
A | B | C | D | |
---|---|---|---|---|
0 | foo | one | x | 1 |
1 | foo | one | y | 3 |
2 | foo | two | x | 2 |
3 | bar | two | y | 5 |
4 | bar | one | x | 4 |
5 | bar | one | y | 1 |
In [17]:
df1.to_csv('ram.csv',sep='@')
In [24]:
df = pd.read_html('https://en.wikipedia.org/wiki/List_of_mandals_in_Andhra_Pradesh')
In [28]:
conda install lxml
conda install html5lib
conda install BeautifulSoup4
In [30]:
df[1]
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) <ipython-input-30-dc0ea82142cb> in <module>() ----> 1 df[1] IndexError: list index out of range
In [31]:
df
Out[31]:
[ 0 1 \ 0 District No. of Mandals 1 Anantapur 63 2 Chittoor[3] 66 3 Kadapa[4] 51 4 East Godavari[5] 64 5 Guntur[6] 57 6 Krishna[7] 53 7 Kurnool[9] 54 8 Nellore[10] 46 9 Prakasam[11] 56 10 Srikakulam[12] 38 11 Visakhapatnam[13] 46 12 Vizianagaram[15] 34 13 West Godavari[16] 48 14 Total Mandals 664 2 0 Mandal Names 1 Agali Amadagur Amarapuram Anantapur Atmakur Ba... 2 B. Kothakota Baireddipalle Bangarupalem Buchin... 3 Atlur B.Kodur Badvel Brahmamgarimatham Chakray... 4 Amalapuram Addateegala Ainavilli Alamuru Allav... 5 Amaravati Amruthalur Achampet Bapatla Bhattipr... 6 A.Konduru Agiripalli Avanigadda Bantumilli Bap... 7 Adoni Allagadda Alur Aspari Atmakur Banaganapa... 8 Allur Ananthasagaram Anumasamudrampeta Atmakur... 9 Addanki Ardhaveedu Ballikuruva Bestavaripeta C... 10 Amadalavalasa Bhamini Burja Etcherla Gara Gang... 11 Anakapalli Anandapuram Ananthagiri Araku Valle... 12 Bhogapuram Badangi Bondapalli Balijipeta Bobbi... 13 Attili Akiveedu Achanta Buttayagudem Bhimavara... 14 NaN ]
In [32]:
df4 = pd.read_html('https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)')
In [38]:
df4[2]
Out[38]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | |
---|---|---|---|---|---|---|---|
0 | Rank | Country or area | UN continental region[2] | UN statistical region[2] | Population (1 July 2016)[3] | Population (1 July 2017)[3] | Change |
1 | — | World | — | — | 7466964280 | 7550262101 | 7000111555135228260♠+1.1% |
2 | 1 | China[a] | Asia | Eastern Asia | 1403500365 | 1409517397 | 6999428716097982630♠+0.4% |
3 | 2 | India | Asia | Southern Asia | 1324171354 | 1339180127 | 7000113344643460699♠+1.1% |
4 | 3 | United States | Americas | Northern America | 322179605 | 324459463 | 6999707635730076710♠+0.7% |
5 | 4 | Indonesia | Asia | South-eastern Asia | 261115456 | 263991379 | 7000110139899186970♠+1.1% |
6 | 5 | Brazil | Americas | South America | 207652865 | 209288278 | 6999787570641031120♠+0.8% |
7 | 6 | Pakistan | Asia | Southern Asia | 193203476 | 197015955 | 7000197329731272540♠+2.0% |
8 | 7 | Nigeria | Africa | Western Africa | 185989640 | 190886311 | 7000263276545940949♠+2.6% |
9 | 8 | Bangladesh | Asia | Southern Asia | 162951560 | 164669751 | 7000105441825779390♠+1.1% |
10 | 9 | Russia | Europe | Eastern Europe | 143964513 | 143989754 | 5000000000000000000♠0.0% |
11 | 10 | Mexico | Americas | Central America | 127540423 | 129163276 | 7000127242246954130♠+1.3% |
12 | 11 | Japan | Asia | Eastern Asia | 127748513 | 127484450 | 3000793294658545260♠−0.2% |
13 | 12 | Ethiopia | Africa | Eastern Africa | 102403196 | 104957438 | 7000249429910371160♠+2.5% |
14 | 13 | Philippines | Asia | South-eastern Asia | 103320222 | 104918090 | 7000154652009942450♠+1.5% |
15 | 14 | Egypt | Africa | Northern Africa | 95688681 | 97553151 | 7000194847497166360♠+1.9% |
16 | 15 | Vietnam | Asia | South-eastern Asia | 94569072 | 95540800 | 7000102753255313749♠+1.0% |
17 | 16 | Germany | Europe | Western Europe | 81914672 | 82114224 | 6999243609594139630♠+0.2% |
18 | 17 | Democratic Republic of the Congo | Africa | Middle Africa | 78736153 | 81339988 | 7000330703863573320♠+3.3% |
19 | 18 | Iran | Asia | Southern Asia | 80277428 | 81162788 | 7000110287539356640♠+1.1% |
20 | 19 | Turkey | Asia | Western Asia | 79512426 | 80745020 | 7000155019040671710♠+1.6% |
21 | 20 | Thailand | Asia | South-eastern Asia | 68863514 | 69037513 | 6999252672264154290♠+0.3% |
22 | 21 | United Kingdom | Europe | Northern Europe | 65788574 | 66181585 | 6999597384889357830♠+0.6% |
23 | 22 | France[b] | Europe | Western Europe | 64720690 | 64979548 | 6999399961743300330♠+0.4% |
24 | 23 | Italy | Europe | Southern Europe | 59429938 | 59359900 | 3000882150306130220♠−0.1% |
25 | 24 | Tanzania[c] | Africa | Eastern Africa | 55572201 | 57310019 | 7000312713545392960♠+3.1% |
26 | 25 | South Africa | Africa | Southern Africa | 56015473 | 56717156 | 7000125265924292030♠+1.3% |
27 | 26 | Myanmar | Asia | South-eastern Asia | 52885223 | 53370609 | 6999917810254860800♠+0.9% |
28 | 27 | South Korea | Asia | Eastern Asia | 50791919 | 50982212 | 6999374652117396870♠+0.4% |
29 | 28 | Colombia | Americas | South America | 48653419 | 49065615 | 6999847208702845740♠+0.8% |
... | ... | ... | ... | ... | ... | ... | ... |
205 | 204 | Dominica | Americas | Caribbean | 73543 | 73925 | 6999519424010442870♠+0.5% |
206 | 205 | Cayman Islands | Americas | Caribbean | 60765 | 61559 | 7000130667324940339♠+1.3% |
207 | 206 | Bermuda | Americas | Northern America | 61666 | 61349 | 3000485940388544740♠−0.5% |
208 | 207 | Greenland | Americas | Northern America | 56412 | 56480 | 6999120541728710210♠+0.1% |
209 | 208 | American Samoa | Oceania | Polynesia | 55599 | 55641 | 6998755409269950880♠+0.1% |
210 | 209 | Saint Kitts and Nevis | Americas | Caribbean | 54821 | 55345 | 6999955838091242400♠+1.0% |
211 | 210 | Northern Mariana Islands | Oceania | Micronesia | 55023 | 55144 | 6999219908038456640♠+0.2% |
212 | 211 | Marshall Islands | Oceania | Micronesia | 53066 | 53127 | 6999114951192854180♠+0.1% |
213 | 212 | Faroe Islands | Europe | Northern Europe | 49117 | 49290 | 6999352220208888990♠+0.4% |
214 | 213 | Sint Maarten | Americas | Caribbean | 39537 | 40120 | 7000147456812605910♠+1.5% |
215 | 214 | Monaco | Europe | Western Europe | 38499 | 38695 | 6999509104132574879♠+0.5% |
216 | 215 | Liechtenstein | Europe | Western Europe | 37666 | 37922 | 6999679658047045080♠+0.7% |
217 | 216 | Turks and Caicos Islands | Americas | Caribbean | 34900 | 35446 | 7000156446991404010♠+1.6% |
218 | 217 | Gibraltar | Europe | Southern Europe | 34408 | 34571 | 6999473727040223190♠+0.5% |
219 | 218 | San Marino | Europe | Southern Europe | 33203 | 33400 | 6999593319880733680♠+0.6% |
220 | 219 | British Virgin Islands | Americas | Caribbean | 30661 | 31196 | 7000174488764228170♠+1.7% |
221 | 220 | Caribbean Netherlands[s] | Americas | Caribbean | 25019 | 25398 | 7000151484871497660♠+1.5% |
222 | 221 | Palau | Oceania | Micronesia | 21503 | 21729 | 7000105101613728320♠+1.1% |
223 | 222 | Cook Islands | Oceania | Polynesia | 17379 | 17380 | 5000000000000000000♠0.0% |
224 | 223 | Anguilla | Americas | Caribbean | 14764 | 14909 | 6999982118667027910♠+1.0% |
225 | 224 | Wallis and Futuna | Oceania | Polynesia | 11899 | 11773 | 2999894108748634340♠−1.1% |
226 | 225 | Nauru | Oceania | Micronesia | 11347 | 11359 | 6999105754825063900♠+0.1% |
227 | 226 | Tuvalu | Oceania | Polynesia | 11097 | 11192 | 6999856087230783100♠+0.9% |
228 | 227 | Saint Pierre and Miquelon | Americas | Northern America | 6305 | 6320 | 6999237906423473430♠+0.2% |
229 | 228 | Montserrat | Americas | Caribbean | 5152 | 5177 | 6999485248447204970♠+0.5% |
230 | 229 | Saint Helena, Ascension and Tristan da Cunha | Africa | Western Africa | 4035 | 4049 | 6999346964064436170♠+0.3% |
231 | 230 | Falkland Islands | Americas | South America | 2910 | 2910 | 5000000000000000000♠0.0% |
232 | 231 | Niue | Oceania | Polynesia | 1624 | 1618 | 3000630541871921189♠−0.4% |
233 | 232 | Tokelau | Oceania | Polynesia | 1282 | 1300 | 7000140405616224650♠+1.4% |
234 | 233 | Vatican City[t] | Europe | Southern Europe | 801 | 792 | 2999887640449438199♠−1.1% |
235 rows × 7 columns
In [43]:
df4[0].to_excel('ram311.xlsx',sheet_name='Sheet1')
No comments:
Post a Comment