How to Add New Variables to a Python Dataframe

sharpsightlabs.com/blog/pandas-as…

[Thread: 1/9]

#data #datascience #Python Image
[2/9]

There are several ways to add a variable to a Python dataframe ...

But my preferred way is the Pandas "assign" method.
[3/9]

The Pandas assign method has fairly simple syntax.

You can use the technique to add a single new variable like this: Image
[4/9]

You can also use the assign method to add multiple new variables at the same time.

This is very convenient if you need to do a lot of data wrangling. Image
[5/9]

If you're doing data wrangling or data cleaning, the assign method becomes even more powerful if you use it in a "chain" of other Pandas methods.

#data #datascience #Python ImageImage
[6/9]

If you don't know how to use the Pandas chaining technique, you can learn about it here:

sharpsightlabs.com/blog/python-pa…
[7/9]

Techniques like the Pandas assign method seem simple, and they are at first.

But once you learn how to use them in simple ways, you can learn to use them in complex ways.
[8/9]

This is the secret to more advanced data analysis and data science.

Learn the basics, then learn how to use them in complex ways.

#data #datascience #DataAnalytics
[9/9]

If you want to learn more about data science, then follow me here: @Josh_Ebner

Every day, I post tutorials and tips to help you learn data science in R and Python.

#data #datascience #Rstats #Python

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Joshua Ebner

Joshua Ebner Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Josh_Ebner

31 Aug
The big thing that I'd change here is the color palette.

This color palette is hard to interpret and frankly, just look a little ugly.

#datascience #DataVisualization

[1/11]
[2/11]

The fix here is pretty simple.

The data are sequential in nature. There's a low and a high.

When you have sequential data, you should almost always look at sequential color palettes.

[3/11]

More specifically:

For sequential data, your go-to palettes should almost always be perceptually uniform sequential palettes like viridis or magma.

Read 11 tweets
30 Aug
If you want to create great data visualizations, you need to understand color palettes.

Here are a few quick tips:

[1/n]

#datascience #datavisualization #Python #rstats
[2/n]

For data that has a sequential ordering (i.e., low to high), you should use sequential color scales.

matplotlib.org/stable/tutoria…

#Python #matplotlib Image
[3/n]

Sequential color scales incrementally change saturation or lightness.

For example, this is a red-sequential color palette: Image
Read 24 tweets
28 Aug
@JoshuaSteinman My understanding based on some research last year and beyond, is that these are deep-water.

... and there's possibly more ports with shallow depth
@JoshuaSteinman For example, @PeterZeihan wrote that Texas has "thirteen world-class deepwater ports"

amzn.to/3BihKN6
@JoshuaSteinman @PeterZeihan Army Corps of Engineers puts it at "15 deep draft ports" and "13 shallow draft ports" along the TX coast.

swd.usace.army.mil/About/Texas-Po…
Read 5 tweets
28 Aug
@JoshuaSteinman Regarding: An American Shenzhen

There's a *lot* of good ports along the Texas coast, and I think much of it under-used.

Great for logistics into the American Heartland, and also into LatAm and Mexico.
@JoshuaSteinman The Texas/Mexico combo provides a unique mix of high-skill, medium-skill, and low-skill labor.

High end design and MFG in TX, lower skill MFG and assembly in MX.
@JoshuaSteinman Also great energy resources in TX (although nuclear would augment).
Read 5 tweets
27 Aug
If you want to master data science in Python, you need to learn Pandas method chaining.



[thread: 1/14]

#data #datascience #Python
[2/14]

Pandas method chains enable you to combine together several individual Pandas techniques in complex ways.
[3/14]

When most people do this, they do it with very long chains of techniques, *all on a single line*.

These are hard to read and hard to debug.

They get more challenging the longer they get.
Read 14 tweets
3 May 20
If there's a large migration of talented people from SF and NYC to Austin, Austin has a shot at being the next Silicon Valley.

#SF #NewYork #SiliconValley #technology #Austin #Texas

(Thread)
2/n

Remember: Texas actually has a long tradition of innovation.

For example, the integrated circuit was invented at Texas Instruments.

en.wikipedia.org/wiki/Texas_Ins…

#technology #tech #Texas ImageImage
3/n

More recently, Amazon, Facebook, Google, and Apple have announced major campuses in Austin.

Google is building a new riverside building, and Facebook already has one.

austin.curbed.com/2019/4/2/18291… ImageImage
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(