python


Output Issues with pandas, Python


Begin Code
import pandas as pd
df = pd.read_csv('C:/Users/lhicks/Documents/Corporate/test.csv', 'r')
saved_column = df.FirstName
saved_column2 = df.LastName
saved_column3 = df.Email
print saved_column
print saved_column2
print saved_column3
Itemlist = []
Itemlist.append(saved_column)
print Itemlist
End of Code
The objective is to select specific columns from a specified xls sheet, grab all the rows from the specified columns, and then print that data out.
The current issue is the data is grabbed correctly, but after 29-30 rows, it prints/stores a "...", and then jumps to line item 880s, and finishes out from there.
The additional issue is that it also stores this as the value, making it worthless due to not providing the full dataset.
The eventual process is to add the selected columns to a new xls sheet to clean up the old data, and then add the rows to a templated document to generate an advertisement letter.
The first question is how to I have all the fields populate? The second is what is the best approach for this? Please provide additional links as well if possible, this is a practical learning experience for me.
Pandas tries to shorten your data when printing it.
NOTE: all the data is still there (print(df.shape) - to check it, print the shape of your DataFrame), it's just a convenient way not to flood your screen with tons of data rows/columns
Try this:
fn = 'C:/Users/lhicks/Documents/Corporate/test.csv'
cols = ['FirstName','LastName','Email']
df = pd.read_csv(fn, usecols=cols)
df.to_excel('/path/to/excel.xlsx', index=False)
This will parse only ['FirstName','LastName','Email'] columns from a CSV file and will export them to Excel file
UPDATE:
if you want to control how many rows should Pandas print:
with pd.option_context("display.max_rows",200):
print(df)

Related Links

giving a name to a pandas dataframe?
mistake comparing datetime, python
numpy testing assert array NOT equal
How to join threads of an asyncio executor runned inside coroutine?
Google Admin SDK insert custom schema using python
Importing images for manifold Isomap
Having nosetests watch files from outside container and rerun tests inside container
Trying to ftp from my system to remote server
Attribute in a Class immediately runs at the wrong time?
Unable to handle “HTTP Badstatus line” exception
How to merge/join two resultset/table in django?
Maximise the Slope using CVXPY
Python-Instagram user_recent_media returning next of none
Django - AttributeError: 'module' object has no attribute 'admin'
Convert pandas (python) categorical x-axis to continuous values when plotting
How to make a specific type of python face tracker

Categories

HOME
batch-processing
plsql
ssas-2012
oauth
concourse
apache2
propertygrid
ext.net
urlencode
vsftpd
pca
xul
gatsby
flann
ctypes
squarespace
postmessage
quartus
tree-traversal
boolean-expression
mousewheel
apple-tv
azure-servicebus-queues
jquery-waypoints
net-snmp
jenkins-job-dsl
partial-application
bxslider
red-black-tree
getjson
read-write
outsystems
m2e
ifstream
fabric-digits
nlb
office365connectors
socketpair
freetts
silverlight-3.0
excel-interop
context-free-language
tableau-server
appstore-approval
rpostgresql
info
uicollectionviewlayout
rxvt
rsqlite
vst
webkit2
dbscan
clob
spring-lemon
gmsmapview
inet
mfc-feature-pack
qt-linguist
axes
interactive-brokers
magento-1.4
datainputstream
direct3d12
file-diffs
rad
jericho-html-parser
p-np
digits
ubercart
xaml-designer
subversion-edge
jython-2.7
odftoolkit
emma
alertifyjs
exiv2
document-database
client-side-scripting
marmalade-edk
mozart-mvc
cbcentralmanager
datarepeater
tfs-power-tools
windows-phone-7-emulator
supersized
entity-framework-ctp5
objectbrowser
ou
datamember
executable-format
for-xml-path
sendfile
surefire
task-management
scala-2.8
system-codedom-compiler
configurable
web-analytics-tools

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App